@@ -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 | |
@@ -53,49 +53,49 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function get_data() { |
55 | 55 | |
56 | - if ( $this->step == 1 ) { |
|
57 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
56 | + if ($this->step == 1) { |
|
57 | + $this->delete_data('give_temp_recount_earnings'); |
|
58 | 58 | } |
59 | 59 | |
60 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
60 | + $total = get_option('give_temp_recount_earnings', false); |
|
61 | 61 | |
62 | - if ( false === $total ) { |
|
62 | + if (false === $total) { |
|
63 | 63 | $total = (float) 0; |
64 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
64 | + $this->store_data('give_temp_recount_earnings', $total); |
|
65 | 65 | } |
66 | 66 | |
67 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
67 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
68 | 68 | |
69 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
69 | + $args = apply_filters('give_recount_earnings_args', array( |
|
70 | 70 | 'number' => $this->per_step, |
71 | 71 | 'page' => $this->step, |
72 | 72 | 'status' => $accepted_statuses, |
73 | 73 | 'fields' => 'ids' |
74 | - ) ); |
|
74 | + )); |
|
75 | 75 | |
76 | - $payments = give_get_payments( $args ); |
|
76 | + $payments = give_get_payments($args); |
|
77 | 77 | |
78 | - if ( ! empty( $payments ) ) { |
|
78 | + if ( ! empty($payments)) { |
|
79 | 79 | |
80 | - foreach ( $payments as $payment ) { |
|
80 | + foreach ($payments as $payment) { |
|
81 | 81 | |
82 | - $total += give_get_payment_amount( $payment ); |
|
82 | + $total += give_get_payment_amount($payment); |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
86 | - if ( $total < 0 ) { |
|
86 | + if ($total < 0) { |
|
87 | 87 | $totals = 0; |
88 | 88 | } |
89 | 89 | |
90 | - $total = round( $total, give_currency_decimal_filter() ); |
|
90 | + $total = round($total, give_currency_decimal_filter()); |
|
91 | 91 | |
92 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
92 | + $this->store_data('give_temp_recount_earnings', $total); |
|
93 | 93 | |
94 | 94 | return true; |
95 | 95 | |
96 | 96 | } |
97 | 97 | |
98 | - update_option( 'give_earnings_total', $total ); |
|
98 | + update_option('give_earnings_total', $total); |
|
99 | 99 | |
100 | 100 | return false; |
101 | 101 | |
@@ -109,25 +109,25 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function get_percentage_complete() { |
111 | 111 | |
112 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
112 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
113 | 113 | |
114 | - if ( false === $total ) { |
|
115 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
114 | + if (false === $total) { |
|
115 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
116 | 116 | |
117 | - $counts = give_count_payments( $args ); |
|
118 | - $total = absint( $counts->publish ); |
|
119 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
117 | + $counts = give_count_payments($args); |
|
118 | + $total = absint($counts->publish); |
|
119 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
120 | 120 | |
121 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
121 | + $this->store_data('give_recount_earnings_total', $total); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | $percentage = 100; |
125 | 125 | |
126 | - if ( $total > 0 ) { |
|
127 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
126 | + if ($total > 0) { |
|
127 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( $percentage > 100 ) { |
|
130 | + if ($percentage > 100) { |
|
131 | 131 | $percentage = 100; |
132 | 132 | } |
133 | 133 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param array $request The Form Data passed into the batch processing |
143 | 143 | */ |
144 | - public function set_properties( $request ) { |
|
144 | + public function set_properties($request) { |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -152,31 +152,31 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function process_step() { |
154 | 154 | |
155 | - if ( ! $this->can_export() ) { |
|
156 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
155 | + if ( ! $this->can_export()) { |
|
156 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | $had_data = $this->get_data(); |
160 | 160 | |
161 | - if ( $had_data ) { |
|
161 | + if ($had_data) { |
|
162 | 162 | $this->done = false; |
163 | 163 | |
164 | 164 | return true; |
165 | 165 | } else { |
166 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
167 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
166 | + $this->delete_data('give_recount_earnings_total'); |
|
167 | + $this->delete_data('give_temp_recount_earnings'); |
|
168 | 168 | $this->done = true; |
169 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
169 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
170 | 170 | |
171 | 171 | return false; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
175 | 175 | public function headers() { |
176 | - ignore_user_abort( true ); |
|
176 | + ignore_user_abort(true); |
|
177 | 177 | |
178 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
179 | - set_time_limit( 0 ); |
|
178 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
179 | + set_time_limit(0); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return mixed Returns the data from the database |
206 | 206 | */ |
207 | - private function get_stored_data( $key ) { |
|
207 | + private function get_stored_data($key) { |
|
208 | 208 | global $wpdb; |
209 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
209 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
210 | 210 | |
211 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
211 | + return empty($value) ? false : maybe_unserialize($value); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return void |
223 | 223 | */ |
224 | - private function store_data( $key, $value ) { |
|
224 | + private function store_data($key, $value) { |
|
225 | 225 | global $wpdb; |
226 | 226 | |
227 | - $value = maybe_serialize( $value ); |
|
227 | + $value = maybe_serialize($value); |
|
228 | 228 | |
229 | 229 | $data = array( |
230 | 230 | 'option_name' => $key, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | '%s', |
239 | 239 | ); |
240 | 240 | |
241 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
241 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return void |
252 | 252 | */ |
253 | - private function delete_data( $key ) { |
|
253 | + private function delete_data($key) { |
|
254 | 254 | global $wpdb; |
255 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
255 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | } |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Export' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Export')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Export. |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'export'; |
46 | - $this->label = __( 'Export', 'give' ); |
|
46 | + $this->label = __('Export', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
50 | - add_action( 'give_admin_field_tools_export', array( $this, 'render_export_field' ), 10, 2 ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | + add_action('give_admin_field_tools_export', array($this, 'render_export_field'), 10, 2); |
|
51 | 51 | |
52 | 52 | // Do not use main donor for this tab. |
53 | - if( give_get_current_setting_tab() === $this->id ) { |
|
54 | - add_action( 'give-tools_open_form', '__return_empty_string' ); |
|
55 | - add_action( 'give-tools_close_form', '__return_empty_string' ); |
|
53 | + if (give_get_current_setting_tab() === $this->id) { |
|
54 | + add_action('give-tools_open_form', '__return_empty_string'); |
|
55 | + add_action('give-tools_close_form', '__return_empty_string'); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * @param array $pages Lst of pages. |
64 | 64 | * @return array |
65 | 65 | */ |
66 | - public function add_settings_page( $pages ) { |
|
67 | - $pages[ $this->id ] = $this->label; |
|
66 | + public function add_settings_page($pages) { |
|
67 | + $pages[$this->id] = $this->label; |
|
68 | 68 | |
69 | 69 | return $pages; |
70 | 70 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param array $settings |
87 | 87 | */ |
88 | 88 | $settings = apply_filters( |
89 | - 'give_get_settings_' . $this->id, |
|
89 | + 'give_get_settings_'.$this->id, |
|
90 | 90 | array( |
91 | 91 | array( |
92 | 92 | 'id' => 'give_tools_export', |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ), |
96 | 96 | array( |
97 | 97 | 'id' => 'export', |
98 | - 'name' => __( 'Export', 'give' ), |
|
98 | + 'name' => __('Export', 'give'), |
|
99 | 99 | 'type' => 'tools_export', |
100 | 100 | ), |
101 | 101 | array( |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function output() { |
120 | 120 | $settings = $this->get_settings(); |
121 | 121 | |
122 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
122 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param $field |
132 | 132 | * @param $option_value |
133 | 133 | */ |
134 | - public function render_export_field( $field, $option_value ) { |
|
135 | - include_once( 'views/html-admin-page-exports.php' ); |
|
134 | + public function render_export_field($field, $option_value) { |
|
135 | + include_once('views/html-admin-page-exports.php'); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 |
@@ -89,7 +89,7 @@ |
||
89 | 89 | add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array( |
90 | 90 | 'read' => true, |
91 | 91 | 'edit_posts' => true, |
92 | - 'edit_pages' => true, |
|
92 | + 'edit_pages' => true, |
|
93 | 93 | 'upload_files' => true, |
94 | 94 | 'delete_posts' => false |
95 | 95 | ) ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function add_roles() { |
52 | - add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array( |
|
52 | + add_role('give_manager', esc_html__('Give Manager', 'give'), array( |
|
53 | 53 | 'read' => true, |
54 | 54 | 'edit_posts' => true, |
55 | 55 | 'delete_posts' => true, |
@@ -78,21 +78,21 @@ discard block |
||
78 | 78 | 'publish_posts' => true, |
79 | 79 | 'read_private_pages' => true, |
80 | 80 | 'read_private_posts' => true |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | - add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array( |
|
83 | + add_role('give_accountant', esc_html__('Give Accountant', 'give'), array( |
|
84 | 84 | 'read' => true, |
85 | 85 | 'edit_posts' => false, |
86 | 86 | 'delete_posts' => false |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | - add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array( |
|
89 | + add_role('give_worker', esc_html__('Give Worker', 'give'), array( |
|
90 | 90 | 'read' => true, |
91 | 91 | 'edit_posts' => true, |
92 | 92 | 'edit_pages' => true, |
93 | 93 | 'upload_files' => true, |
94 | 94 | 'delete_posts' => false |
95 | - ) ); |
|
95 | + )); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -111,38 +111,38 @@ discard block |
||
111 | 111 | public function add_caps() { |
112 | 112 | global $wp_roles; |
113 | 113 | |
114 | - if ( class_exists( 'WP_Roles' ) ) { |
|
115 | - if ( ! isset( $wp_roles ) ) { |
|
114 | + if (class_exists('WP_Roles')) { |
|
115 | + if ( ! isset($wp_roles)) { |
|
116 | 116 | $wp_roles = new WP_Roles(); |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if ( is_object( $wp_roles ) ) { |
|
121 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
122 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
123 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
124 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
120 | + if (is_object($wp_roles)) { |
|
121 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
122 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
123 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
124 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
125 | 125 | |
126 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
127 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
128 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
129 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
126 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
127 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
128 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
129 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
130 | 130 | |
131 | 131 | // Add the main post type capabilities. |
132 | 132 | $capabilities = $this->get_core_caps(); |
133 | - foreach ( $capabilities as $cap_group ) { |
|
134 | - foreach ( $cap_group as $cap ) { |
|
135 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
136 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
137 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
133 | + foreach ($capabilities as $cap_group) { |
|
134 | + foreach ($cap_group as $cap) { |
|
135 | + $wp_roles->add_cap('administrator', $cap); |
|
136 | + $wp_roles->add_cap('give_manager', $cap); |
|
137 | + $wp_roles->add_cap('give_worker', $cap); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
142 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
143 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
144 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
145 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
141 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
142 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
143 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
144 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
145 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | } |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | public function get_core_caps() { |
161 | 161 | $capabilities = array(); |
162 | 162 | |
163 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
163 | + $capability_types = array('give_form', 'give_payment'); |
|
164 | 164 | |
165 | - foreach ( $capability_types as $capability_type ) { |
|
166 | - $capabilities[ $capability_type ] = array( |
|
165 | + foreach ($capability_types as $capability_type) { |
|
166 | + $capabilities[$capability_type] = array( |
|
167 | 167 | // Post type. |
168 | 168 | "edit_{$capability_type}", |
169 | 169 | "read_{$capability_type}", |
@@ -209,22 +209,22 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @return array $caps Meta capabilities. |
211 | 211 | */ |
212 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
212 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
213 | 213 | |
214 | - switch ( $cap ) { |
|
214 | + switch ($cap) { |
|
215 | 215 | |
216 | 216 | case 'view_give_form_stats' : |
217 | 217 | |
218 | - if ( empty( $args[0] ) ) { |
|
218 | + if (empty($args[0])) { |
|
219 | 219 | break; |
220 | 220 | } |
221 | 221 | |
222 | - $form = get_post( $args[0] ); |
|
223 | - if ( empty( $form ) ) { |
|
222 | + $form = get_post($args[0]); |
|
223 | + if (empty($form)) { |
|
224 | 224 | break; |
225 | 225 | } |
226 | 226 | |
227 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
227 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
228 | 228 | $caps = array(); |
229 | 229 | } |
230 | 230 | |
@@ -251,41 +251,41 @@ discard block |
||
251 | 251 | |
252 | 252 | global $wp_roles; |
253 | 253 | |
254 | - if ( class_exists( 'WP_Roles' ) ) { |
|
255 | - if ( ! isset( $wp_roles ) ) { |
|
254 | + if (class_exists('WP_Roles')) { |
|
255 | + if ( ! isset($wp_roles)) { |
|
256 | 256 | $wp_roles = new WP_Roles(); |
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | - if ( is_object( $wp_roles ) ) { |
|
260 | + if (is_object($wp_roles)) { |
|
261 | 261 | // Give Manager Capabilities. |
262 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
263 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
264 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
265 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
262 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
263 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
264 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
265 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
266 | 266 | |
267 | 267 | // Site Administrator Capabilities. |
268 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
269 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
270 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
271 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
268 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
269 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
270 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
271 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
272 | 272 | |
273 | 273 | // Remove the Main Post Type Capabilities. |
274 | 274 | $capabilities = $this->get_core_caps(); |
275 | 275 | |
276 | - foreach ( $capabilities as $cap_group ) { |
|
277 | - foreach ( $cap_group as $cap ) { |
|
278 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
279 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
280 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
276 | + foreach ($capabilities as $cap_group) { |
|
277 | + foreach ($cap_group as $cap) { |
|
278 | + $wp_roles->remove_cap('give_manager', $cap); |
|
279 | + $wp_roles->remove_cap('administrator', $cap); |
|
280 | + $wp_roles->remove_cap('give_worker', $cap); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
284 | 284 | /** Give Accountant Capabilities */ |
285 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
286 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
287 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
288 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
285 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
286 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
287 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
288 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
289 | 289 | |
290 | 290 | } |
291 | 291 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array|bool Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return array Variable prices |
67 | 67 | */ |
68 | -function give_get_variable_price_ids( $form_id = 0 ) { |
|
69 | - if( ! ( $prices = give_get_variable_prices( $form_id ) ) ) { |
|
68 | +function give_get_variable_price_ids($form_id = 0) { |
|
69 | + if ( ! ($prices = give_get_variable_prices($form_id))) { |
|
70 | 70 | return array(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $price_ids = array(); |
74 | - foreach ( $prices as $price ){ |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | $price_ids[] = $price['_give_id']['level_id']; |
76 | 76 | } |
77 | 77 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string $default_price |
91 | 91 | */ |
92 | -function give_get_default_multilevel_amount( $form_id ) { |
|
92 | +function give_get_default_multilevel_amount($form_id) { |
|
93 | 93 | $default_price = '1.00'; |
94 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
94 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
95 | 95 | |
96 | - foreach ( $prices as $price ) { |
|
96 | + foreach ($prices as $price) { |
|
97 | 97 | |
98 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
98 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
99 | 99 | $default_price = $price['_give_amount']; |
100 | 100 | } |
101 | 101 | |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | * @return string $default_price |
117 | 117 | * @since 1.0 |
118 | 118 | */ |
119 | -function give_get_default_form_amount( $form_id ) { |
|
119 | +function give_get_default_form_amount($form_id) { |
|
120 | 120 | |
121 | - if ( give_has_variable_prices( $form_id ) ) { |
|
121 | + if (give_has_variable_prices($form_id)) { |
|
122 | 122 | |
123 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
123 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
124 | 124 | |
125 | 125 | } else { |
126 | 126 | |
127 | - $default_amount = give_get_meta( $form_id, '_give_set_price', true ); |
|
127 | + $default_amount = give_get_meta($form_id, '_give_set_price', true); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - return apply_filters( 'give_default_form_amount', $default_amount ); |
|
131 | + return apply_filters('give_default_form_amount', $default_amount); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
149 | +function give_is_custom_price_mode($form_id = 0) { |
|
150 | 150 | |
151 | - if ( empty( $form_id ) ) { |
|
151 | + if (empty($form_id)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $form = new Give_Donate_Form( $form_id ); |
|
155 | + $form = new Give_Donate_Form($form_id); |
|
156 | 156 | |
157 | 157 | return $form->is_custom_price_mode(); |
158 | 158 | } |
159 | 159 | \ No newline at end of file |
@@ -254,8 +254,8 @@ |
||
254 | 254 | $args = array( |
255 | 255 | 'id' => 'give-api-user-search', |
256 | 256 | 'name' => 'user_id', |
257 | - ); |
|
258 | - echo Give()->html->ajax_user_search($args); ?> |
|
257 | + ); |
|
258 | + echo Give()->html->ajax_user_search($args); ?> |
|
259 | 259 | <?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?> |
260 | 260 | <?php |
261 | 261 | $give_api_is_bottom = true; |
@@ -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 | /** |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | global $status, $page; |
54 | 54 | |
55 | 55 | // Set parent defaults |
56 | - parent::__construct( array( |
|
57 | - 'singular' => esc_html__( 'API Key', 'give' ), // Singular name of the listed records |
|
58 | - 'plural' => esc_html__( 'API Keys', 'give' ), // Plural name of the listed records |
|
59 | - 'ajax' => false,// Does this table support ajax? |
|
60 | - ) ); |
|
56 | + parent::__construct(array( |
|
57 | + 'singular' => esc_html__('API Key', 'give'), // Singular name of the listed records |
|
58 | + 'plural' => esc_html__('API Keys', 'give'), // Plural name of the listed records |
|
59 | + 'ajax' => false, // Does this table support ajax? |
|
60 | + )); |
|
61 | 61 | |
62 | 62 | $this->query(); |
63 | 63 | } |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string Column Name |
75 | 75 | */ |
76 | - public function column_default( $item, $column_name ) { |
|
77 | - return $item[ $column_name ]; |
|
76 | + public function column_default($item, $column_name) { |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return string Column Name |
89 | 89 | */ |
90 | - public function column_key( $item ) { |
|
91 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['key'] ) . '"/>'; |
|
90 | + public function column_key($item) { |
|
91 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['key']).'"/>'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string Column Name |
103 | 103 | */ |
104 | - public function column_token( $item ) { |
|
105 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['token'] ) . '"/>'; |
|
104 | + public function column_token($item) { |
|
105 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['token']).'"/>'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return string Column Name |
117 | 117 | */ |
118 | - public function column_secret( $item ) { |
|
119 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['secret'] ) . '"/>'; |
|
118 | + public function column_secret($item) { |
|
119 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['secret']).'"/>'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,46 +126,46 @@ discard block |
||
126 | 126 | * @since 1.1 |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - public function column_user( $item ) { |
|
129 | + public function column_user($item) { |
|
130 | 130 | |
131 | 131 | $actions = array(); |
132 | 132 | |
133 | - if ( apply_filters( 'give_api_log_requests', true ) ) { |
|
133 | + if (apply_filters('give_api_log_requests', true)) { |
|
134 | 134 | $actions['view'] = sprintf( |
135 | 135 | '<a href="%s">%s</a>', |
136 | - esc_url( add_query_arg( array( |
|
136 | + esc_url(add_query_arg(array( |
|
137 | 137 | 'section' => 'api_requests', |
138 | 138 | 'post_type' => 'give_forms', |
139 | 139 | 'page' => 'give-tools', |
140 | 140 | 'tab' => 'logs', |
141 | 141 | 's' => $item['email'], |
142 | - ), 'edit.php' ) ), |
|
143 | - esc_html__( 'View API Log', 'give' ) |
|
142 | + ), 'edit.php')), |
|
143 | + esc_html__('View API Log', 'give') |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $actions['reissue'] = sprintf( |
148 | 148 | '<a href="%s" class="give-regenerate-api-key">%s</a>', |
149 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
149 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
150 | 150 | 'user_id' => $item['id'], |
151 | 151 | 'give_action' => 'process_api_key', |
152 | 152 | 'give_api_process' => 'regenerate', |
153 | - ) ), 'give-api-nonce' ) ), |
|
154 | - esc_html__( 'Reissue', 'give' ) |
|
153 | + )), 'give-api-nonce')), |
|
154 | + esc_html__('Reissue', 'give') |
|
155 | 155 | ); |
156 | - $actions['revoke'] = sprintf( |
|
156 | + $actions['revoke'] = sprintf( |
|
157 | 157 | '<a href="%s" class="give-revoke-api-key give-delete">%s</a>', |
158 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
158 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
159 | 159 | 'user_id' => $item['id'], |
160 | 160 | 'give_action' => 'process_api_key', |
161 | 161 | 'give_api_process' => 'revoke', |
162 | - ) ), 'give-api-nonce' ) ), |
|
163 | - esc_html__( 'Revoke', 'give' ) |
|
162 | + )), 'give-api-nonce')), |
|
163 | + esc_html__('Revoke', 'give') |
|
164 | 164 | ); |
165 | 165 | |
166 | - $actions = apply_filters( 'give_api_row_actions', array_filter( $actions ) ); |
|
166 | + $actions = apply_filters('give_api_row_actions', array_filter($actions)); |
|
167 | 167 | |
168 | - return sprintf( '%1$s %2$s', $item['user'], $this->row_actions( $actions ) ); |
|
168 | + return sprintf('%1$s %2$s', $item['user'], $this->row_actions($actions)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function get_columns() { |
191 | 191 | $columns = array( |
192 | - 'user' => esc_html__( 'Username', 'give' ), |
|
193 | - 'key' => esc_html__( 'Public Key', 'give' ), |
|
194 | - 'token' => esc_html__( 'Token', 'give' ), |
|
195 | - 'secret' => esc_html__( 'Secret Key', 'give' ), |
|
192 | + 'user' => esc_html__('Username', 'give'), |
|
193 | + 'key' => esc_html__('Public Key', 'give'), |
|
194 | + 'token' => esc_html__('Token', 'give'), |
|
195 | + 'secret' => esc_html__('Secret Key', 'give'), |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | return $columns; |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param string $which |
208 | 208 | */ |
209 | - protected function display_tablenav( $which ) { |
|
210 | - if ( 'top' === $which ) { |
|
211 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
209 | + protected function display_tablenav($which) { |
|
210 | + if ('top' === $which) { |
|
211 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
212 | 212 | } |
213 | 213 | ?> |
214 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
214 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
215 | 215 | |
216 | 216 | <div class="alignleft actions bulkactions"> |
217 | - <?php $this->bulk_actions( $which ); ?> |
|
217 | + <?php $this->bulk_actions($which); ?> |
|
218 | 218 | </div> |
219 | 219 | |
220 | 220 | <?php |
221 | - $this->extra_tablenav( $which ); |
|
222 | - $this->pagination( $which ); |
|
221 | + $this->extra_tablenav($which); |
|
222 | + $this->pagination($which); |
|
223 | 223 | ?> |
224 | 224 | |
225 | 225 | <br class="clear"/> |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - function bulk_actions( $which = '' ) { |
|
240 | + function bulk_actions($which = '') { |
|
241 | 241 | // These aren't really bulk actions but this outputs the markup in the right place. |
242 | 242 | static $give_api_is_bottom; |
243 | 243 | |
244 | - if ( $give_api_is_bottom ) { |
|
244 | + if ($give_api_is_bottom) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | ?> |
248 | 248 | <input type="hidden" name="give_action" value="process_api_key"/> |
249 | 249 | <input type="hidden" name="give_api_process" value="generate"/> |
250 | - <?php wp_nonce_field( 'give-api-nonce' ); |
|
250 | + <?php wp_nonce_field('give-api-nonce'); |
|
251 | 251 | /** |
252 | 252 | * API Key user search. |
253 | 253 | */ |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'name' => 'user_id', |
257 | 257 | ); |
258 | 258 | echo Give()->html->ajax_user_search($args); ?> |
259 | - <?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?> |
|
259 | + <?php submit_button(esc_html__('Generate New API Keys', 'give'), 'secondary', 'submit', false); ?> |
|
260 | 260 | <?php |
261 | 261 | $give_api_is_bottom = true; |
262 | 262 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @return int Current page number |
270 | 270 | */ |
271 | 271 | public function get_paged() { |
272 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
272 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -280,21 +280,21 @@ discard block |
||
280 | 280 | * @return array |
281 | 281 | */ |
282 | 282 | public function query() { |
283 | - $users = get_users( array( |
|
283 | + $users = get_users(array( |
|
284 | 284 | 'meta_value' => 'give_user_secret_key', |
285 | 285 | 'number' => $this->per_page, |
286 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
287 | - ) ); |
|
288 | - $keys = array(); |
|
289 | - |
|
290 | - foreach ( $users as $user ) { |
|
291 | - $keys[ $user->ID ]['id'] = $user->ID; |
|
292 | - $keys[ $user->ID ]['email'] = $user->user_email; |
|
293 | - $keys[ $user->ID ]['user'] = '<a href="' . add_query_arg( 'user_id', $user->ID, 'user-edit.php' ) . '"><strong>' . $user->user_login . '</strong></a>'; |
|
294 | - |
|
295 | - $keys[ $user->ID ]['key'] = Give()->api->get_user_public_key( $user->ID ); |
|
296 | - $keys[ $user->ID ]['secret'] = Give()->api->get_user_secret_key( $user->ID ); |
|
297 | - $keys[ $user->ID ]['token'] = Give()->api->get_token( $user->ID ); |
|
286 | + 'offset' => $this->per_page * ($this->get_paged() - 1), |
|
287 | + )); |
|
288 | + $keys = array(); |
|
289 | + |
|
290 | + foreach ($users as $user) { |
|
291 | + $keys[$user->ID]['id'] = $user->ID; |
|
292 | + $keys[$user->ID]['email'] = $user->user_email; |
|
293 | + $keys[$user->ID]['user'] = '<a href="'.add_query_arg('user_id', $user->ID, 'user-edit.php').'"><strong>'.$user->user_login.'</strong></a>'; |
|
294 | + |
|
295 | + $keys[$user->ID]['key'] = Give()->api->get_user_public_key($user->ID); |
|
296 | + $keys[$user->ID]['secret'] = Give()->api->get_user_secret_key($user->ID); |
|
297 | + $keys[$user->ID]['token'] = Give()->api->get_token($user->ID); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | return $keys; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | public function total_items() { |
312 | 312 | global $wpdb; |
313 | 313 | |
314 | - if ( ! ( $total_items = Give_Cache::get( 'give_total_api_keys', true ) ) ) { |
|
314 | + if ( ! ($total_items = Give_Cache::get('give_total_api_keys', true))) { |
|
315 | 315 | $total_items = $wpdb->get_var( |
316 | 316 | $wpdb->prepare( |
317 | 317 | "SELECT count(user_id) |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | ) |
321 | 321 | ); |
322 | 322 | |
323 | - Give_Cache::set( 'give_total_api_keys', $total_items, HOUR_IN_SECONDS, true ); |
|
323 | + Give_Cache::set('give_total_api_keys', $total_items, HOUR_IN_SECONDS, true); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return $total_items; |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $hidden = array(); // No hidden columns |
340 | 340 | $sortable = array(); // Not sortable... for now |
341 | 341 | |
342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
342 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
343 | 343 | |
344 | 344 | $data = $this->query(); |
345 | 345 | |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | |
348 | 348 | $this->items = $data; |
349 | 349 | |
350 | - $this->set_pagination_args( array( |
|
350 | + $this->set_pagination_args(array( |
|
351 | 351 | 'total_items' => $total_items, |
352 | 352 | 'per_page' => $this->per_page, |
353 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
353 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | } |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | ) |
48 | 48 | ); |
49 | 49 | |
50 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
51 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
50 | + $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
51 | + $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
52 | 52 | |
53 | 53 | $pdf = new give_pdf(); |
54 | 54 | $pdf->AddPage( 'L', 'A4' ); |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
81 | 81 | $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
82 | 82 | |
83 | - // Display Categories Heading only, if user has opted for it. |
|
84 | - if ( $categories_enabled ) { |
|
83 | + // Display Categories Heading only, if user has opted for it. |
|
84 | + if ( $categories_enabled ) { |
|
85 | 85 | $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - // Display Tags Heading only, if user has opted for it. |
|
89 | - if ( $tags_enabled ) { |
|
88 | + // Display Tags Heading only, if user has opted for it. |
|
89 | + if ( $tags_enabled ) { |
|
90 | 90 | $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | 93 | $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
94 | 94 | $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | $price = give_currency_filter( give_get_form_price( $form->ID ), '', true ); |
126 | 126 | } |
127 | 127 | |
128 | - // Display Categories Data only, if user has opted for it. |
|
129 | - if ( $categories_enabled ) { |
|
130 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
131 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
132 | - } |
|
128 | + // Display Categories Data only, if user has opted for it. |
|
129 | + if ( $categories_enabled ) { |
|
130 | + $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
131 | + $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
132 | + } |
|
133 | 133 | |
134 | - // Display Tags Data only, if user has opted for it. |
|
135 | - if ( $tags_enabled ) { |
|
136 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
137 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
138 | - } |
|
134 | + // Display Tags Data only, if user has opted for it. |
|
135 | + if ( $tags_enabled ) { |
|
136 | + $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
137 | + $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | $sales = give_get_form_sales_stats( $form->ID ); |
141 | 141 | $link = get_permalink( $form->ID ); |
@@ -147,38 +147,38 @@ discard block |
||
147 | 147 | $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
148 | 148 | } |
149 | 149 | |
150 | - // This will help filter data before appending it to PDF Receipt. |
|
151 | - $prepare_pdf_data = array(); |
|
152 | - $prepare_pdf_data[] = $title; |
|
153 | - $prepare_pdf_data[] = $price; |
|
150 | + // This will help filter data before appending it to PDF Receipt. |
|
151 | + $prepare_pdf_data = array(); |
|
152 | + $prepare_pdf_data[] = $title; |
|
153 | + $prepare_pdf_data[] = $price; |
|
154 | 154 | |
155 | - // Append Categories Data only, if user has opted for it. |
|
156 | - if ( $categories_enabled ) { |
|
157 | - $prepare_pdf_data[] = $categories; |
|
158 | - } |
|
155 | + // Append Categories Data only, if user has opted for it. |
|
156 | + if ( $categories_enabled ) { |
|
157 | + $prepare_pdf_data[] = $categories; |
|
158 | + } |
|
159 | 159 | |
160 | - // Append Tags Data only, if user has opted for it. |
|
161 | - if ( $tags_enabled ) { |
|
162 | - $prepare_pdf_data[] = $tags; |
|
163 | - } |
|
160 | + // Append Tags Data only, if user has opted for it. |
|
161 | + if ( $tags_enabled ) { |
|
162 | + $prepare_pdf_data[] = $tags; |
|
163 | + } |
|
164 | 164 | |
165 | - $prepare_pdf_data[] = $sales; |
|
166 | - $prepare_pdf_data[] = $earnings; |
|
165 | + $prepare_pdf_data[] = $sales; |
|
166 | + $prepare_pdf_data[] = $earnings; |
|
167 | 167 | |
168 | 168 | $pdf->Row( $prepare_pdf_data ); |
169 | 169 | endforeach; |
170 | 170 | } else { |
171 | 171 | |
172 | - // Fix: Minor Styling Alignment Issue for PDF |
|
173 | - if( $categories_enabled && $tags_enabled ) { |
|
174 | - $pdf->SetWidths( array( 280 ) ); |
|
175 | - } elseif( $categories_enabled || $tags_enabled ) { |
|
176 | - $pdf->SetWidths( array( 235 ) ); |
|
177 | - } else { |
|
178 | - $pdf->SetWidths( array( 190 ) ); |
|
179 | - } |
|
172 | + // Fix: Minor Styling Alignment Issue for PDF |
|
173 | + if( $categories_enabled && $tags_enabled ) { |
|
174 | + $pdf->SetWidths( array( 280 ) ); |
|
175 | + } elseif( $categories_enabled || $tags_enabled ) { |
|
176 | + $pdf->SetWidths( array( 235 ) ); |
|
177 | + } else { |
|
178 | + $pdf->SetWidths( array( 190 ) ); |
|
179 | + } |
|
180 | 180 | |
181 | - $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
181 | + $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
182 | 182 | $pdf->Row( array( $title ) ); |
183 | 183 | } |
184 | 184 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly.. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,94 +25,94 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @uses give_pdf |
27 | 27 | */ |
28 | -function give_generate_pdf( $data ) { |
|
28 | +function give_generate_pdf($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
31 | - wp_die( __( 'You do not have permission to generate PDF sales reports.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('view_give_reports')) { |
|
31 | + wp_die(__('You do not have permission to generate PDF sales reports.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
35 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
35 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
36 | 36 | } |
37 | 37 | |
38 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php'; |
|
39 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php'; |
|
38 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php'; |
|
39 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php'; |
|
40 | 40 | |
41 | 41 | $daterange = utf8_decode( |
42 | 42 | sprintf( |
43 | 43 | /* translators: 1: start date 2: end date */ |
44 | - __( '%1$s to %2$s', 'give' ), |
|
45 | - date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
46 | - date_i18n( give_date_format() ) |
|
44 | + __('%1$s to %2$s', 'give'), |
|
45 | + date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
46 | + date_i18n(give_date_format()) |
|
47 | 47 | ) |
48 | 48 | ); |
49 | 49 | |
50 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
51 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
50 | + $categories_enabled = give_is_setting_enabled(give_get_option('categories', 'disabled')); |
|
51 | + $tags_enabled = give_is_setting_enabled(give_get_option('tags', 'disabled')); |
|
52 | 52 | |
53 | 53 | $pdf = new give_pdf(); |
54 | - $pdf->AddPage( 'L', 'A4' ); |
|
54 | + $pdf->AddPage('L', 'A4'); |
|
55 | 55 | |
56 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
57 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
58 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
56 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
57 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
58 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
59 | 59 | |
60 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 ); |
|
60 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8); |
|
61 | 61 | |
62 | - $pdf->SetMargins( 8, 8, 8 ); |
|
63 | - $pdf->SetX( 8 ); |
|
62 | + $pdf->SetMargins(8, 8, 8); |
|
63 | + $pdf->SetX(8); |
|
64 | 64 | |
65 | - $pdf->SetFont( 'Helvetica', '', 16 ); |
|
66 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
67 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
65 | + $pdf->SetFont('Helvetica', '', 16); |
|
66 | + $pdf->SetTextColor(50, 50, 50); |
|
67 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
68 | 68 | |
69 | - $pdf->SetFont( 'Helvetica', '', 13 ); |
|
69 | + $pdf->SetFont('Helvetica', '', 13); |
|
70 | 70 | $pdf->Ln(); |
71 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
72 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
71 | + $pdf->SetTextColor(150, 150, 150); |
|
72 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
73 | 73 | $pdf->Ln(); |
74 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
75 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
76 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
77 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
74 | + $pdf->SetTextColor(50, 50, 50); |
|
75 | + $pdf->SetFont('Helvetica', '', 14); |
|
76 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
77 | + $pdf->SetFont('Helvetica', '', 12); |
|
78 | 78 | |
79 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
80 | - $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
81 | - $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
79 | + $pdf->SetFillColor(238, 238, 238); |
|
80 | + $pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
81 | + $pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
82 | 82 | |
83 | 83 | // Display Categories Heading only, if user has opted for it. |
84 | - if ( $categories_enabled ) { |
|
85 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
84 | + if ($categories_enabled) { |
|
85 | + $pdf->Cell(45, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // Display Tags Heading only, if user has opted for it. |
89 | - if ( $tags_enabled ) { |
|
90 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
89 | + if ($tags_enabled) { |
|
90 | + $pdf->Cell(45, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
91 | 91 | } |
92 | 92 | |
93 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
94 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
93 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
94 | + $pdf->Cell(45, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
95 | 95 | |
96 | - $year = date( 'Y' ); |
|
97 | - $give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) ); |
|
96 | + $year = date('Y'); |
|
97 | + $give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1)); |
|
98 | 98 | |
99 | - if ( $give_forms ) { |
|
100 | - $pdf->SetWidths( array( 70, 30, 45, 45, 45, 45 ) ); |
|
99 | + if ($give_forms) { |
|
100 | + $pdf->SetWidths(array(70, 30, 45, 45, 45, 45)); |
|
101 | 101 | |
102 | - foreach ( $give_forms as $form ): |
|
103 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
102 | + foreach ($give_forms as $form): |
|
103 | + $pdf->SetFillColor(255, 255, 255); |
|
104 | 104 | |
105 | 105 | $title = $form->post_title; |
106 | 106 | |
107 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
107 | + if (give_has_variable_prices($form->ID)) { |
|
108 | 108 | |
109 | - $prices = give_get_variable_prices( $form->ID ); |
|
109 | + $prices = give_get_variable_prices($form->ID); |
|
110 | 110 | |
111 | 111 | $first = $prices[0]['_give_amount']; |
112 | - $last = array_pop( $prices ); |
|
112 | + $last = array_pop($prices); |
|
113 | 113 | $last = $last['_give_amount']; |
114 | 114 | |
115 | - if ( $first < $last ) { |
|
115 | + if ($first < $last) { |
|
116 | 116 | $min = $first; |
117 | 117 | $max = $last; |
118 | 118 | } else { |
@@ -120,31 +120,31 @@ discard block |
||
120 | 120 | $max = $first; |
121 | 121 | } |
122 | 122 | |
123 | - $price = give_currency_filter( give_format_amount( $min, array( 'sanitize' => false ) ), '', true ) . ' - ' . give_currency_filter( give_format_amount( $max ), '', true ); |
|
123 | + $price = give_currency_filter(give_format_amount($min, array('sanitize' => false)), '', true).' - '.give_currency_filter(give_format_amount($max), '', true); |
|
124 | 124 | } else { |
125 | - $price = give_currency_filter( give_get_form_price( $form->ID ), '', true ); |
|
125 | + $price = give_currency_filter(give_get_form_price($form->ID), '', true); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Display Categories Data only, if user has opted for it. |
129 | - if ( $categories_enabled ) { |
|
130 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
131 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
129 | + if ($categories_enabled) { |
|
130 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
131 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // Display Tags Data only, if user has opted for it. |
135 | - if ( $tags_enabled ) { |
|
136 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
137 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
135 | + if ($tags_enabled) { |
|
136 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
137 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
138 | 138 | } |
139 | 139 | |
140 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
141 | - $link = get_permalink( $form->ID ); |
|
142 | - $earnings = give_currency_filter( give_get_form_earnings_stats( $form->ID ), '', true ); |
|
140 | + $sales = give_get_form_sales_stats($form->ID); |
|
141 | + $link = get_permalink($form->ID); |
|
142 | + $earnings = give_currency_filter(give_get_form_earnings_stats($form->ID), '', true); |
|
143 | 143 | |
144 | - if ( function_exists( 'iconv' ) ) { |
|
144 | + if (function_exists('iconv')) { |
|
145 | 145 | // Ensure characters like euro; are properly converted. |
146 | - $price = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) ); |
|
147 | - $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
|
146 | + $price = iconv('UTF-8', 'windows-1252', utf8_encode($price)); |
|
147 | + $earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings)); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // This will help filter data before appending it to PDF Receipt. |
@@ -153,51 +153,51 @@ discard block |
||
153 | 153 | $prepare_pdf_data[] = $price; |
154 | 154 | |
155 | 155 | // Append Categories Data only, if user has opted for it. |
156 | - if ( $categories_enabled ) { |
|
156 | + if ($categories_enabled) { |
|
157 | 157 | $prepare_pdf_data[] = $categories; |
158 | 158 | } |
159 | 159 | |
160 | 160 | // Append Tags Data only, if user has opted for it. |
161 | - if ( $tags_enabled ) { |
|
161 | + if ($tags_enabled) { |
|
162 | 162 | $prepare_pdf_data[] = $tags; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $prepare_pdf_data[] = $sales; |
166 | 166 | $prepare_pdf_data[] = $earnings; |
167 | 167 | |
168 | - $pdf->Row( $prepare_pdf_data ); |
|
168 | + $pdf->Row($prepare_pdf_data); |
|
169 | 169 | endforeach; |
170 | 170 | } else { |
171 | 171 | |
172 | 172 | // Fix: Minor Styling Alignment Issue for PDF |
173 | - if( $categories_enabled && $tags_enabled ) { |
|
174 | - $pdf->SetWidths( array( 280 ) ); |
|
175 | - } elseif( $categories_enabled || $tags_enabled ) { |
|
176 | - $pdf->SetWidths( array( 235 ) ); |
|
173 | + if ($categories_enabled && $tags_enabled) { |
|
174 | + $pdf->SetWidths(array(280)); |
|
175 | + } elseif ($categories_enabled || $tags_enabled) { |
|
176 | + $pdf->SetWidths(array(235)); |
|
177 | 177 | } else { |
178 | - $pdf->SetWidths( array( 190 ) ); |
|
178 | + $pdf->SetWidths(array(190)); |
|
179 | 179 | } |
180 | 180 | |
181 | - $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
182 | - $pdf->Row( array( $title ) ); |
|
181 | + $title = utf8_decode(__('No forms found.', 'give')); |
|
182 | + $pdf->Row(array($title)); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | $pdf->Ln(); |
186 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
187 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
188 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
189 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
190 | - |
|
191 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
192 | - $image = str_replace( ' ', '%20', $image ); |
|
193 | - |
|
194 | - $pdf->SetX( 25 ); |
|
195 | - $pdf->Image( $image . '&file=.png' ); |
|
196 | - $pdf->Ln( 7 ); |
|
197 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
186 | + $pdf->SetTextColor(50, 50, 50); |
|
187 | + $pdf->SetFont('Helvetica', '', 14); |
|
188 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
189 | + $pdf->SetFont('Helvetica', '', 12); |
|
190 | + |
|
191 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
192 | + $image = str_replace(' ', '%20', $image); |
|
193 | + |
|
194 | + $pdf->SetX(25); |
|
195 | + $pdf->Image($image.'&file=.png'); |
|
196 | + $pdf->Ln(7); |
|
197 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
198 | 198 | } |
199 | 199 | |
200 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
200 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Draws Chart for PDF Report. |
@@ -214,38 +214,38 @@ discard block |
||
214 | 214 | * @return string $chart->getUrl() URL for the Google Chart |
215 | 215 | */ |
216 | 216 | function give_draw_chart_image() { |
217 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
218 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
219 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
217 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
218 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
219 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
220 | 220 | |
221 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
221 | + $chart = new GoogleChart('lc', 900, 330); |
|
222 | 222 | |
223 | 223 | $i = 1; |
224 | 224 | $earnings = ""; |
225 | 225 | $sales = ""; |
226 | 226 | |
227 | - while ( $i <= 12 ) : |
|
228 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
229 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
230 | - $i ++; |
|
227 | + while ($i <= 12) : |
|
228 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
229 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
230 | + $i++; |
|
231 | 231 | endwhile; |
232 | 232 | |
233 | - $earnings_array = explode( ",", $earnings ); |
|
234 | - $sales_array = explode( ",", $sales ); |
|
233 | + $earnings_array = explode(",", $earnings); |
|
234 | + $sales_array = explode(",", $sales); |
|
235 | 235 | |
236 | 236 | $i = 0; |
237 | - while ( $i <= 11 ) { |
|
238 | - if ( empty( $sales_array[ $i ] ) ) { |
|
239 | - $sales_array[ $i ] = 0; |
|
237 | + while ($i <= 11) { |
|
238 | + if (empty($sales_array[$i])) { |
|
239 | + $sales_array[$i] = 0; |
|
240 | 240 | } |
241 | - $i ++; |
|
241 | + $i++; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | $min_earnings = 0; |
245 | - $max_earnings = max( $earnings_array ); |
|
246 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
245 | + $max_earnings = max($earnings_array); |
|
246 | + $earnings_scale = round($max_earnings, - 1); |
|
247 | 247 | |
248 | - $data = new GoogleChartData( array( |
|
248 | + $data = new GoogleChartData(array( |
|
249 | 249 | $earnings_array[0], |
250 | 250 | $earnings_array[1], |
251 | 251 | $earnings_array[2], |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | $earnings_array[9], |
259 | 259 | $earnings_array[10], |
260 | 260 | $earnings_array[11] |
261 | - ) ); |
|
261 | + )); |
|
262 | 262 | |
263 | - $data->setLegend( __( 'Income', 'give' ) ); |
|
264 | - $data->setColor( '1b58a3' ); |
|
265 | - $chart->addData( $data ); |
|
263 | + $data->setLegend(__('Income', 'give')); |
|
264 | + $data->setColor('1b58a3'); |
|
265 | + $chart->addData($data); |
|
266 | 266 | |
267 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
268 | - $shape_marker->setColor( '000000' ); |
|
269 | - $shape_marker->setSize( 7 ); |
|
270 | - $shape_marker->setBorder( 2 ); |
|
271 | - $shape_marker->setData( $data ); |
|
272 | - $chart->addMarker( $shape_marker ); |
|
267 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
268 | + $shape_marker->setColor('000000'); |
|
269 | + $shape_marker->setSize(7); |
|
270 | + $shape_marker->setBorder(2); |
|
271 | + $shape_marker->setData($data); |
|
272 | + $chart->addMarker($shape_marker); |
|
273 | 273 | |
274 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
275 | - $value_marker->setColor( '000000' ); |
|
276 | - $value_marker->setData( $data ); |
|
277 | - $chart->addMarker( $value_marker ); |
|
274 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
275 | + $value_marker->setColor('000000'); |
|
276 | + $value_marker->setData($data); |
|
277 | + $chart->addMarker($value_marker); |
|
278 | 278 | |
279 | - $data = new GoogleChartData( array( |
|
279 | + $data = new GoogleChartData(array( |
|
280 | 280 | $sales_array[0], |
281 | 281 | $sales_array[1], |
282 | 282 | $sales_array[2], |
@@ -289,46 +289,46 @@ discard block |
||
289 | 289 | $sales_array[9], |
290 | 290 | $sales_array[10], |
291 | 291 | $sales_array[11] |
292 | - ) ); |
|
293 | - $data->setLegend( __( 'Donations', 'give' ) ); |
|
294 | - $data->setColor( 'ff6c1c' ); |
|
295 | - $chart->addData( $data ); |
|
296 | - |
|
297 | - $chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
298 | - |
|
299 | - $chart->setScale( 0, $max_earnings ); |
|
300 | - |
|
301 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
302 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
303 | - $chart->addAxis( $y_axis ); |
|
304 | - |
|
305 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
306 | - $x_axis->setTickMarks( 5 ); |
|
307 | - $x_axis->setLabels( array( |
|
308 | - __( 'Jan', 'give' ), |
|
309 | - __( 'Feb', 'give' ), |
|
310 | - __( 'Mar', 'give' ), |
|
311 | - __( 'Apr', 'give' ), |
|
312 | - __( 'May', 'give' ), |
|
313 | - __( 'June', 'give' ), |
|
314 | - __( 'July', 'give' ), |
|
315 | - __( 'Aug', 'give' ), |
|
316 | - __( 'Sept', 'give' ), |
|
317 | - __( 'Oct', 'give' ), |
|
318 | - __( 'Nov', 'give' ), |
|
319 | - __( 'Dec', 'give' ) |
|
320 | - ) ); |
|
321 | - $chart->addAxis( $x_axis ); |
|
322 | - |
|
323 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
324 | - $shape_marker->setSize( 6 ); |
|
325 | - $shape_marker->setBorder( 2 ); |
|
326 | - $shape_marker->setData( $data ); |
|
327 | - $chart->addMarker( $shape_marker ); |
|
328 | - |
|
329 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
330 | - $value_marker->setData( $data ); |
|
331 | - $chart->addMarker( $value_marker ); |
|
292 | + )); |
|
293 | + $data->setLegend(__('Donations', 'give')); |
|
294 | + $data->setColor('ff6c1c'); |
|
295 | + $chart->addData($data); |
|
296 | + |
|
297 | + $chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
298 | + |
|
299 | + $chart->setScale(0, $max_earnings); |
|
300 | + |
|
301 | + $y_axis = new GoogleChartAxis('y'); |
|
302 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
303 | + $chart->addAxis($y_axis); |
|
304 | + |
|
305 | + $x_axis = new GoogleChartAxis('x'); |
|
306 | + $x_axis->setTickMarks(5); |
|
307 | + $x_axis->setLabels(array( |
|
308 | + __('Jan', 'give'), |
|
309 | + __('Feb', 'give'), |
|
310 | + __('Mar', 'give'), |
|
311 | + __('Apr', 'give'), |
|
312 | + __('May', 'give'), |
|
313 | + __('June', 'give'), |
|
314 | + __('July', 'give'), |
|
315 | + __('Aug', 'give'), |
|
316 | + __('Sept', 'give'), |
|
317 | + __('Oct', 'give'), |
|
318 | + __('Nov', 'give'), |
|
319 | + __('Dec', 'give') |
|
320 | + )); |
|
321 | + $chart->addAxis($x_axis); |
|
322 | + |
|
323 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
324 | + $shape_marker->setSize(6); |
|
325 | + $shape_marker->setBorder(2); |
|
326 | + $shape_marker->setData($data); |
|
327 | + $chart->addMarker($shape_marker); |
|
328 | + |
|
329 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
330 | + $value_marker->setData($data); |
|
331 | + $chart->addMarker($value_marker); |
|
332 | 332 | |
333 | 333 | return $chart->getUrl(); |
334 | 334 | } |
@@ -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; |
@@ -84,43 +84,43 @@ discard block |
||
84 | 84 | 'paged' => $this->step |
85 | 85 | ); |
86 | 86 | |
87 | - $forms = new WP_Query( $args ); |
|
87 | + $forms = new WP_Query($args); |
|
88 | 88 | |
89 | - if ( $forms->posts ) { |
|
90 | - foreach ( $forms->posts as $form ) { |
|
89 | + if ($forms->posts) { |
|
90 | + foreach ($forms->posts as $form) { |
|
91 | 91 | |
92 | 92 | $row = []; |
93 | 93 | |
94 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
94 | + foreach ($this->csv_cols() as $key => $value) { |
|
95 | 95 | |
96 | 96 | // Setup default value/ |
97 | - $row[ $key ] = ''; |
|
97 | + $row[$key] = ''; |
|
98 | 98 | |
99 | - if ( in_array( $key, $meta ) ) { |
|
99 | + if (in_array($key, $meta)) { |
|
100 | 100 | |
101 | - switch ( $key ) { |
|
101 | + switch ($key) { |
|
102 | 102 | |
103 | 103 | case '_thumbnail_id' : |
104 | 104 | |
105 | - $image_id = get_post_thumbnail_id( $form->ID ); |
|
106 | - $row[ $key ] = wp_get_attachment_url( $image_id ); |
|
105 | + $image_id = get_post_thumbnail_id($form->ID); |
|
106 | + $row[$key] = wp_get_attachment_url($image_id); |
|
107 | 107 | |
108 | 108 | break; |
109 | 109 | |
110 | 110 | case 'give_price' : |
111 | 111 | |
112 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
112 | + if (give_has_variable_prices($form->ID)) { |
|
113 | 113 | |
114 | 114 | $prices = []; |
115 | - foreach ( give_get_variable_prices( $form->ID ) as $price ) { |
|
116 | - $prices[] = $price['name'] . ': ' . $price['amount']; |
|
115 | + foreach (give_get_variable_prices($form->ID) as $price) { |
|
116 | + $prices[] = $price['name'].': '.$price['amount']; |
|
117 | 117 | } |
118 | 118 | |
119 | - $row[ $key ] = implode( ' | ', $prices ); |
|
119 | + $row[$key] = implode(' | ', $prices); |
|
120 | 120 | |
121 | 121 | } else { |
122 | 122 | |
123 | - $row[ $key ] = give_get_form_price( $form->ID ); |
|
123 | + $row[$key] = give_get_form_price($form->ID); |
|
124 | 124 | |
125 | 125 | } |
126 | 126 | |
@@ -128,44 +128,44 @@ discard block |
||
128 | 128 | |
129 | 129 | default : |
130 | 130 | |
131 | - $row[ $key ] = give_get_meta( $form->ID, $key, TRUE ); |
|
131 | + $row[$key] = give_get_meta($form->ID, $key, TRUE); |
|
132 | 132 | |
133 | 133 | break; |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | - } elseif ( isset( $form->$key ) ) { |
|
137 | + } elseif (isset($form->$key)) { |
|
138 | 138 | |
139 | - switch ( $key ) { |
|
139 | + switch ($key) { |
|
140 | 140 | |
141 | 141 | case 'post_author' : |
142 | 142 | |
143 | - $row[ $key ] = get_the_author_meta( 'user_login', $form->post_author ); |
|
143 | + $row[$key] = get_the_author_meta('user_login', $form->post_author); |
|
144 | 144 | |
145 | 145 | break; |
146 | 146 | |
147 | 147 | default : |
148 | 148 | |
149 | - $row[ $key ] = $form->$key; |
|
149 | + $row[$key] = $form->$key; |
|
150 | 150 | |
151 | 151 | break; |
152 | 152 | } |
153 | 153 | |
154 | - } elseif ( 'tags' == $key ) { |
|
154 | + } elseif ('tags' == $key) { |
|
155 | 155 | |
156 | - $terms = get_the_terms( $form->ID, 'form_tag' ); |
|
157 | - if ( $terms ) { |
|
158 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
159 | - $row[ $key ] = implode( ' | ', $terms ); |
|
156 | + $terms = get_the_terms($form->ID, 'form_tag'); |
|
157 | + if ($terms) { |
|
158 | + $terms = wp_list_pluck($terms, 'name'); |
|
159 | + $row[$key] = implode(' | ', $terms); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | - } elseif ( 'categories' == $key ) { |
|
163 | + } elseif ('categories' == $key) { |
|
164 | 164 | |
165 | - $terms = get_the_terms( $form->ID, 'form_category' ); |
|
166 | - if ( $terms ) { |
|
167 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
168 | - $row[ $key ] = implode( ' | ', $terms ); |
|
165 | + $terms = get_the_terms($form->ID, 'form_category'); |
|
166 | + if ($terms) { |
|
167 | + $terms = wp_list_pluck($terms, 'name'); |
|
168 | + $row[$key] = implode(' | ', $terms); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | } |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
180 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
179 | + $data = apply_filters('give_export_get_data', $data); |
|
180 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
181 | 181 | |
182 | 182 | return $data; |
183 | 183 | |
@@ -197,20 +197,20 @@ discard block |
||
197 | 197 | |
198 | 198 | $args = array( |
199 | 199 | 'post_type' => 'give_forms', |
200 | - 'posts_per_page' => - 1, |
|
200 | + 'posts_per_page' => -1, |
|
201 | 201 | 'post_status' => 'any', |
202 | 202 | 'fields' => 'ids', |
203 | 203 | ); |
204 | 204 | |
205 | - $forms = new WP_Query( $args ); |
|
205 | + $forms = new WP_Query($args); |
|
206 | 206 | $total = (int) $forms->post_count; |
207 | 207 | $percentage = 100; |
208 | 208 | |
209 | - if ( $total > 0 ) { |
|
210 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
209 | + if ($total > 0) { |
|
210 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
211 | 211 | } |
212 | 212 | |
213 | - if ( $percentage > 100 ) { |
|
213 | + if ($percentage > 100) { |
|
214 | 214 | $percentage = 100; |
215 | 215 | } |
216 | 216 |
@@ -216,7 +216,6 @@ |
||
216 | 216 | /** |
217 | 217 | * Set Donation Amount for Multi Level Donation Forms |
218 | 218 | * |
219 | - * @param int $form_id |
|
220 | 219 | * @param object $form |
221 | 220 | * |
222 | 221 | * @since 1.8.9 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | 27 | |
28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
29 | 29 | |
30 | 30 | // Add backward compatibility to give-action param ( $_GET ) |
31 | - if( empty( $_get_action ) ) { |
|
32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
31 | + if (empty($_get_action)) { |
|
32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
33 | 33 | } |
34 | 34 | |
35 | - if ( isset( $_get_action ) ) { |
|
35 | + if (isset($_get_action)) { |
|
36 | 36 | /** |
37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
38 | 38 | * |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $_GET Array of HTTP GET variables. |
42 | 42 | */ |
43 | - do_action( "give_{$_get_action}", $_GET ); |
|
43 | + do_action("give_{$_get_action}", $_GET); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | -add_action( 'init', 'give_get_actions' ); |
|
48 | +add_action('init', 'give_get_actions'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function give_post_actions() { |
60 | 60 | |
61 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
61 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
62 | 62 | |
63 | 63 | |
64 | 64 | // Add backward compatibility to give-action param ( $_POST ). |
65 | - if( empty( $_post_action ) ) { |
|
66 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
65 | + if (empty($_post_action)) { |
|
66 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
67 | 67 | } |
68 | 68 | |
69 | - if ( isset( $_post_action ) ) { |
|
69 | + if (isset($_post_action)) { |
|
70 | 70 | /** |
71 | 71 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
72 | 72 | * |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param array $_POST Array of HTTP POST variables. |
76 | 76 | */ |
77 | - do_action( "give_{$_post_action}", $_POST ); |
|
77 | + do_action("give_{$_post_action}", $_POST); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | -add_action( 'init', 'give_post_actions' ); |
|
82 | +add_action('init', 'give_post_actions'); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Connect WordPress user with Donor. |
@@ -89,28 +89,28 @@ discard block |
||
89 | 89 | * @param array $user_data User Data |
90 | 90 | * @return void |
91 | 91 | */ |
92 | -function give_connect_donor_to_wpuser( $user_id, $user_data ){ |
|
92 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
93 | 93 | /* @var Give_Donor $donor */ |
94 | - $donor = new Give_Donor( $user_data['user_email'] ); |
|
94 | + $donor = new Give_Donor($user_data['user_email']); |
|
95 | 95 | |
96 | 96 | // Validate donor id and check if do nor is already connect to wp user or not. |
97 | - if( $donor->id && ! $donor->user_id ) { |
|
97 | + if ($donor->id && ! $donor->user_id) { |
|
98 | 98 | |
99 | 99 | // Update donor user_id. |
100 | - if( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
101 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
102 | - $donor->add_note( $donor_note ); |
|
100 | + if ($donor->update(array('user_id' => $user_id))) { |
|
101 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
102 | + $donor->add_note($donor_note); |
|
103 | 103 | |
104 | 104 | // Update user_id meta in payments. |
105 | - if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
|
106 | - foreach ( $donations as $donation ) { |
|
107 | - give_update_meta( $donation, '_give_payment_user_id', $user_id ); |
|
105 | + if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) { |
|
106 | + foreach ($donations as $donation) { |
|
107 | + give_update_meta($donation, '_give_payment_user_id', $user_id); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
113 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
113 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | /** |
@@ -124,24 +124,24 @@ discard block |
||
124 | 124 | function give_validate_license_when_site_migrated() { |
125 | 125 | // Store current site address if not already stored. |
126 | 126 | $homeurl = home_url(); |
127 | - if( ! get_option( 'give_site_address_before_migrate' ) ) { |
|
127 | + if ( ! get_option('give_site_address_before_migrate')) { |
|
128 | 128 | // Update site address. |
129 | - update_option( 'give_site_address_before_migrate', $homeurl ); |
|
129 | + update_option('give_site_address_before_migrate', $homeurl); |
|
130 | 130 | |
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | - if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) { |
|
134 | + if ($homeurl !== get_option('give_site_address_before_migrate')) { |
|
135 | 135 | // Immediately run cron. |
136 | - wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' ); |
|
136 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
137 | 137 | |
138 | 138 | // Update site address. |
139 | - update_option( 'give_site_address_before_migrate', home_url() ); |
|
139 | + update_option('give_site_address_before_migrate', home_url()); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | } |
143 | -add_action( 'init', 'give_validate_license_when_site_migrated' ); |
|
144 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
143 | +add_action('init', 'give_validate_license_when_site_migrated'); |
|
144 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
|
145 | 145 | |
146 | 146 | |
147 | 147 | /** |
@@ -150,18 +150,18 @@ discard block |
||
150 | 150 | * @since 1.8 |
151 | 151 | * @param $data |
152 | 152 | */ |
153 | -function give_donor_batch_export_complete( $data ) { |
|
153 | +function give_donor_batch_export_complete($data) { |
|
154 | 154 | // Remove donor ids cache. |
155 | - if( |
|
156 | - isset( $data['class'] ) |
|
155 | + if ( |
|
156 | + isset($data['class']) |
|
157 | 157 | && 'Give_Batch_Donors_Export' === $data['class'] |
158 | - && ! empty( $data['forms'] ) |
|
159 | - && isset( $data['give_export_option']['query_id'] ) |
|
158 | + && ! empty($data['forms']) |
|
159 | + && isset($data['give_export_option']['query_id']) |
|
160 | 160 | ) { |
161 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
161 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
162 | 162 | } |
163 | 163 | } |
164 | -add_action('give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
164 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
|
165 | 165 | |
166 | 166 | /** |
167 | 167 | * Print css for wordpress setting pages. |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | /* @var WP_Screen $screen */ |
173 | 173 | $screen = get_current_screen(); |
174 | 174 | |
175 | - if( ! ( $screen instanceof WP_Screen ) ) { |
|
175 | + if ( ! ($screen instanceof WP_Screen)) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
179 | - switch ( true ) { |
|
180 | - case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ): |
|
179 | + switch (true) { |
|
180 | + case ('plugins' === $screen->base || 'plugins-network' === $screen->base): |
|
181 | 181 | ?> |
182 | 182 | <style> |
183 | 183 | tr.active.update + tr.give-addon-notice-tr td{ |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | <?php |
211 | 211 | } |
212 | 212 | } |
213 | -add_action( 'admin_head', 'give_admin_quick_css' ); |
|
213 | +add_action('admin_head', 'give_admin_quick_css'); |
|
214 | 214 | |
215 | 215 | |
216 | 216 | /** |
@@ -223,28 +223,28 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return void |
225 | 225 | */ |
226 | -function give_set_donation_levels_max_min_amount( $form_id ) { |
|
226 | +function give_set_donation_levels_max_min_amount($form_id) { |
|
227 | 227 | if ( |
228 | - ( 'set' === $_POST['_give_price_option'] ) || |
|
229 | - ( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) || |
|
230 | - ! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) ) |
|
228 | + ('set' === $_POST['_give_price_option']) || |
|
229 | + (in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) || |
|
230 | + ! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount')) |
|
231 | 231 | ) { |
232 | 232 | // Delete old meta. |
233 | - give_delete_meta( $form_id, '_give_levels_minimum_amount' ); |
|
234 | - give_delete_meta( $form_id, '_give_levels_maximum_amount' ); |
|
233 | + give_delete_meta($form_id, '_give_levels_minimum_amount'); |
|
234 | + give_delete_meta($form_id, '_give_levels_maximum_amount'); |
|
235 | 235 | |
236 | 236 | return; |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Sanitize donation level amounts. |
240 | - $donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts ); |
|
240 | + $donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts); |
|
241 | 241 | |
242 | - $min_amount = min( $donation_levels_amounts ); |
|
243 | - $max_amount = max( $donation_levels_amounts ); |
|
242 | + $min_amount = min($donation_levels_amounts); |
|
243 | + $max_amount = max($donation_levels_amounts); |
|
244 | 244 | |
245 | 245 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
246 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 ); |
|
247 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount? give_sanitize_amount_for_db( $max_amount ) : 0 ); |
|
246 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0); |
|
247 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0); |
|
248 | 248 | } |
249 | 249 | |
250 | -add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 ); |
|
251 | 250 | \ No newline at end of file |
251 | +add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30); |
|
252 | 252 | \ No newline at end of file |
@@ -253,7 +253,7 @@ |
||
253 | 253 | * |
254 | 254 | * @access public |
255 | 255 | * @since 1.0 |
256 | - * @return mixed string If search is present, false otherwise. |
|
256 | + * @return string|false string If search is present, false otherwise. |
|
257 | 257 | */ |
258 | 258 | public function get_search() { |
259 | 259 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -12,13 +12,13 @@ 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 | |
19 | 19 | // Load WP_List_Table if not loaded |
20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
20 | +if ( ! class_exists('WP_List_Table')) { |
|
21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults |
64 | - parent::__construct( array( |
|
65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
67 | - 'ajax' => false,// Does this table support ajax?. |
|
68 | - ) ); |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
67 | + 'ajax' => false, // Does this table support ajax?. |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
88 | 88 | } |
89 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
90 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
89 | + if ( ! empty($_REQUEST['order'])) { |
|
90 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
91 | 91 | } |
92 | 92 | ?> |
93 | 93 | <p class="search-box" role="search"> |
94 | 94 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
95 | 95 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
96 | - <?php submit_button( $text, 'button', false, false, array( |
|
96 | + <?php submit_button($text, 'button', false, false, array( |
|
97 | 97 | 'ID' => 'search-submit', |
98 | - ) ); ?> |
|
98 | + )); ?> |
|
99 | 99 | </p> |
100 | 100 | <?php |
101 | 101 | } |
@@ -111,27 +111,27 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string Column Name. |
113 | 113 | */ |
114 | - public function column_default( $donor, $column_name ) { |
|
115 | - switch ( $column_name ) { |
|
114 | + public function column_default($donor, $column_name) { |
|
115 | + switch ($column_name) { |
|
116 | 116 | |
117 | 117 | case 'num_donations' : |
118 | - $value = '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . urlencode( $donor['id'] ) ) . '&status=publish' . ' ">' . esc_html( $donor['num_donations'] ) . '</a>'; |
|
118 | + $value = '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.urlencode($donor['id'])).'&status=publish'.' ">'.esc_html($donor['num_donations']).'</a>'; |
|
119 | 119 | break; |
120 | 120 | |
121 | 121 | case 'amount_spent' : |
122 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); |
|
122 | + $value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false))); |
|
123 | 123 | break; |
124 | 124 | |
125 | 125 | case 'date_created' : |
126 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
126 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
127 | 127 | break; |
128 | 128 | |
129 | 129 | default: |
130 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
130 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
131 | 131 | break; |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( "give_report_column_{$column_name}", $value, $donor['id'] ); |
|
134 | + return apply_filters("give_report_column_{$column_name}", $value, $donor['id']); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function column_name( $donor ) { |
|
146 | - $name = '#' . $donor['id'] . ' '; |
|
147 | - $name .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
148 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
149 | - $actions = $this->get_row_actions( $donor ); |
|
145 | + public function column_name($donor) { |
|
146 | + $name = '#'.$donor['id'].' '; |
|
147 | + $name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
148 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
149 | + $actions = $this->get_row_actions($donor); |
|
150 | 150 | |
151 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
151 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_columns() { |
162 | 162 | $columns = array( |
163 | - 'name' => __( 'Name', 'give' ), |
|
164 | - 'email' => __( 'Email', 'give' ), |
|
165 | - 'num_donations' => __( 'Donations', 'give' ), |
|
166 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
167 | - 'date_created' => __( 'Date Created', 'give' ), |
|
163 | + 'name' => __('Name', 'give'), |
|
164 | + 'email' => __('Email', 'give'), |
|
165 | + 'num_donations' => __('Donations', 'give'), |
|
166 | + 'amount_spent' => __('Total Donated', 'give'), |
|
167 | + 'date_created' => __('Date Created', 'give'), |
|
168 | 168 | ); |
169 | 169 | |
170 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
170 | + return apply_filters('give_list_donors_columns', $columns); |
|
171 | 171 | |
172 | 172 | } |
173 | 173 | |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | public function get_sortable_columns() { |
182 | 182 | |
183 | 183 | $columns = array( |
184 | - 'date_created' => array( 'date_created', true ), |
|
185 | - 'name' => array( 'name', true ), |
|
186 | - 'num_donations' => array( 'purchase_count', false ), |
|
187 | - 'amount_spent' => array( 'purchase_value', false ), |
|
184 | + 'date_created' => array('date_created', true), |
|
185 | + 'name' => array('name', true), |
|
186 | + 'num_donations' => array('purchase_count', false), |
|
187 | + 'amount_spent' => array('purchase_value', false), |
|
188 | 188 | ); |
189 | 189 | |
190 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
190 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -200,19 +200,19 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array An array of action links. |
202 | 202 | */ |
203 | - public function get_row_actions( $donor ) { |
|
203 | + public function get_row_actions($donor) { |
|
204 | 204 | |
205 | 205 | $actions = array( |
206 | 206 | |
207 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
207 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
208 | 208 | |
209 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
209 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
210 | 210 | |
211 | - 'delete' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor['id'] ), sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
211 | + 'delete' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor['id']), sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
212 | 212 | |
213 | 213 | ); |
214 | 214 | |
215 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
215 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @since 1.0 |
227 | 227 | * @return void |
228 | 228 | */ |
229 | - public function bulk_actions( $which = '' ) { |
|
229 | + public function bulk_actions($which = '') { |
|
230 | 230 | // These aren't really bulk actions but this outputs the markup in the right place. |
231 | 231 | } |
232 | 232 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @return int Current page number. |
239 | 239 | */ |
240 | 240 | public function get_paged() { |
241 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
241 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @return mixed string If search is present, false otherwise. |
250 | 250 | */ |
251 | 251 | public function get_search() { |
252 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
252 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | |
267 | 267 | // Get donor query. |
268 | 268 | $args = $this->get_donor_query(); |
269 | - $donors = Give()->donors->get_donors( $args ); |
|
269 | + $donors = Give()->donors->get_donors($args); |
|
270 | 270 | |
271 | - if ( $donors ) { |
|
271 | + if ($donors) { |
|
272 | 272 | |
273 | - foreach ( $donors as $donor ) { |
|
273 | + foreach ($donors as $donor) { |
|
274 | 274 | |
275 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
275 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
276 | 276 | |
277 | 277 | $data[] = array( |
278 | 278 | 'id' => $donor->id, |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
289 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
289 | + return apply_filters('give_donors_column_query_data', $data); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | |
302 | 302 | $_donor_query['number'] = - 1; |
303 | 303 | $_donor_query['offset'] = 0; |
304 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
304 | + $donors = Give()->donors->get_donors($_donor_query); |
|
305 | 305 | |
306 | - return count( $donors ); |
|
306 | + return count($donors); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function get_donor_query() { |
317 | 317 | $paged = $this->get_paged(); |
318 | - $offset = $this->per_page * ( $paged - 1 ); |
|
318 | + $offset = $this->per_page * ($paged - 1); |
|
319 | 319 | $search = $this->get_search(); |
320 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
321 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
320 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
321 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
322 | 322 | |
323 | 323 | $args = array( |
324 | 324 | 'number' => $this->per_page, |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | 'orderby' => $orderby, |
328 | 328 | ); |
329 | 329 | |
330 | - if ( $search ) { |
|
331 | - if ( is_email( $search ) ) { |
|
330 | + if ($search) { |
|
331 | + if (is_email($search)) { |
|
332 | 332 | $args['email'] = $search; |
333 | - } elseif ( is_numeric( $search ) ) { |
|
333 | + } elseif (is_numeric($search)) { |
|
334 | 334 | $args['id'] = $search; |
335 | 335 | } else { |
336 | 336 | $args['name'] = $search; |
@@ -353,16 +353,16 @@ discard block |
||
353 | 353 | $hidden = array(); // No hidden columns. |
354 | 354 | $sortable = $this->get_sortable_columns(); |
355 | 355 | |
356 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
356 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
357 | 357 | |
358 | 358 | $this->items = $this->donor_data(); |
359 | 359 | |
360 | 360 | $this->total = $this->get_donor_count(); |
361 | 361 | |
362 | - $this->set_pagination_args( array( |
|
362 | + $this->set_pagination_args(array( |
|
363 | 363 | 'total_items' => $this->total, |
364 | 364 | 'per_page' => $this->per_page, |
365 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
366 | - ) ); |
|
365 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
366 | + )); |
|
367 | 367 | } |
368 | 368 | } |