@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | // Exit if accessed directly. |
19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
19 | +if ( ! defined('ABSPATH')) { |
|
20 | 20 | exit; |
21 | 21 | } |
22 | 22 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * @return void |
30 | 30 | */ |
31 | 31 | function give_reports_page() { |
32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' ); |
|
33 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
32 | + $current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); |
|
33 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
34 | 34 | $views = give_reports_default_views(); |
35 | 35 | ?> |
36 | 36 | <div class="wrap give-settings-page"> |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | <h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1> |
39 | 39 | |
40 | 40 | <h2 class="nav-tab-wrapper"> |
41 | - <?php foreach ( $views as $tab => $label ) { ?> |
|
42 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
41 | + <?php foreach ($views as $tab => $label) { ?> |
|
42 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
43 | 43 | 'tab' => $tab, |
44 | 44 | 'settings-updated' => false, |
45 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a> |
|
45 | + ), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a> |
|
46 | 46 | <?php } ?> |
47 | - <?php if ( current_user_can( 'export_give_reports' ) ) { ?> |
|
48 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
47 | + <?php if (current_user_can('export_give_reports')) { ?> |
|
48 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
49 | 49 | 'tab' => 'export', |
50 | 50 | 'settings-updated' => false, |
51 | - ), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a> |
|
51 | + ), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a> |
|
52 | 52 | <?php } |
53 | 53 | /** |
54 | 54 | * Fires in the report tabs. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @since 1.0 |
59 | 59 | */ |
60 | - do_action( 'give_reports_tabs' ); |
|
60 | + do_action('give_reports_tabs'); |
|
61 | 61 | ?> |
62 | 62 | </h2> |
63 | 63 | |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @since 1.0 |
69 | 69 | */ |
70 | - do_action( 'give_reports_page_top' ); |
|
70 | + do_action('give_reports_page_top'); |
|
71 | 71 | |
72 | 72 | // Set $active_tab prior to hook firing. |
73 | - if ( in_array( $active_tab, array_keys( $views ) ) ) { |
|
73 | + if (in_array($active_tab, array_keys($views))) { |
|
74 | 74 | $active_tab = 'reports'; |
75 | 75 | } |
76 | 76 | |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @since 1.0 |
81 | 81 | */ |
82 | - do_action( "give_reports_tab_{$active_tab}" ); |
|
82 | + do_action("give_reports_tab_{$active_tab}"); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Fires after the report page. |
86 | 86 | * |
87 | 87 | * @since 1.0 |
88 | 88 | */ |
89 | - do_action( 'give_reports_page_bottom' ); |
|
89 | + do_action('give_reports_page_bottom'); |
|
90 | 90 | ?> |
91 | 91 | </div><!-- .wrap --> |
92 | 92 | <?php |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function give_reports_default_views() { |
102 | 102 | $views = array( |
103 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
104 | - 'forms' => esc_html__( 'Forms', 'give' ), |
|
105 | - 'donors' => esc_html__( 'Donors', 'give' ), |
|
106 | - 'gateways' => esc_html__( 'Donation Methods', 'give' ), |
|
103 | + 'earnings' => esc_html__('Income', 'give'), |
|
104 | + 'forms' => esc_html__('Forms', 'give'), |
|
105 | + 'donors' => esc_html__('Donors', 'give'), |
|
106 | + 'gateways' => esc_html__('Donation Methods', 'give'), |
|
107 | 107 | ); |
108 | 108 | |
109 | - $views = apply_filters( 'give_report_views', $views ); |
|
109 | + $views = apply_filters('give_report_views', $views); |
|
110 | 110 | |
111 | 111 | return $views; |
112 | 112 | } |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | * @since 1.0 |
122 | 122 | * @return string $view Report View |
123 | 123 | */ |
124 | -function give_get_reporting_view( $default = 'earnings' ) { |
|
124 | +function give_get_reporting_view($default = 'earnings') { |
|
125 | 125 | |
126 | - if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { |
|
126 | + if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { |
|
127 | 127 | $view = $default; |
128 | 128 | } else { |
129 | 129 | $view = $_GET['view']; |
130 | 130 | } |
131 | 131 | |
132 | - return apply_filters( 'give_get_reporting_view', $view ); |
|
132 | + return apply_filters('give_get_reporting_view', $view); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $current_view = 'earnings'; |
143 | 143 | $views = give_reports_default_views(); |
144 | 144 | |
145 | - if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) { |
|
145 | + if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) { |
|
146 | 146 | $current_view = $_GET['tab']; |
147 | 147 | } |
148 | 148 | |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @since 1.0 |
153 | 153 | */ |
154 | - do_action( "give_reports_view_{$current_view}" ); |
|
154 | + do_action("give_reports_view_{$current_view}"); |
|
155 | 155 | } |
156 | 156 | |
157 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' ); |
|
157 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * Renders the Reports Page Views Drop Downs |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | */ |
165 | 165 | function give_report_views() { |
166 | 166 | $views = give_reports_default_views(); |
167 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings'; |
|
167 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings'; |
|
168 | 168 | /** |
169 | 169 | * Fires before the report page actions form. |
170 | 170 | * |
171 | 171 | * @since 1.0 |
172 | 172 | */ |
173 | - do_action( 'give_report_view_actions_before' ); |
|
173 | + do_action('give_report_view_actions_before'); |
|
174 | 174 | ?> |
175 | 175 | <form id="give-reports-filter" method="get"> |
176 | 176 | <select id="give-reports-view" name="view"> |
177 | - <option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option> |
|
178 | - <?php foreach ( $views as $view_id => $label ) : ?> |
|
179 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
177 | + <option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option> |
|
178 | + <?php foreach ($views as $view_id => $label) : ?> |
|
179 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
180 | 180 | <?php endforeach; ?> |
181 | 181 | </select> |
182 | 182 | |
@@ -188,12 +188,12 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @since 1.0 |
190 | 190 | */ |
191 | - do_action( 'give_report_view_actions' ); |
|
191 | + do_action('give_report_view_actions'); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <input type="hidden" name="post_type" value="give_forms"/> |
195 | 195 | <input type="hidden" name="page" value="give-reports"/> |
196 | - <?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?> |
|
196 | + <?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?> |
|
197 | 197 | </form> |
198 | 198 | <?php |
199 | 199 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @since 1.0 |
203 | 203 | */ |
204 | - do_action( 'give_report_view_actions_after' ); |
|
204 | + do_action('give_report_view_actions_after'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -214,18 +214,18 @@ discard block |
||
214 | 214 | */ |
215 | 215 | function give_reports_forms_table() { |
216 | 216 | |
217 | - if ( isset( $_GET['form-id'] ) ) { |
|
217 | + if (isset($_GET['form-id'])) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
221 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' ); |
|
221 | + include(dirname(__FILE__).'/class-form-reports-table.php'); |
|
222 | 222 | |
223 | 223 | $give_table = new Give_Form_Reports_Table(); |
224 | 224 | $give_table->prepare_items(); |
225 | 225 | $give_table->display(); |
226 | 226 | } |
227 | 227 | |
228 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' ); |
|
228 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Renders the detailed report for a specific give form |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | * @return void |
235 | 235 | */ |
236 | 236 | function give_reports_form_details() { |
237 | - if ( ! isset( $_GET['form-id'] ) ) { |
|
237 | + if ( ! isset($_GET['form-id'])) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | ?> |
241 | 241 | <div class="tablenav top reports-forms-details-wrap"> |
242 | 242 | <div class="actions bulkactions"> |
243 | - <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button> |
|
243 | + <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button> |
|
244 | 244 | </div> |
245 | 245 | </div> |
246 | 246 | <?php |
247 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) ); |
|
247 | + give_reports_graph_of_form(absint($_GET['form-id'])); |
|
248 | 248 | } |
249 | 249 | |
250 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' ); |
|
250 | +add_action('give_reports_view_forms', 'give_reports_form_details'); |
|
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Renders the Reports Donors Table |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @return void |
259 | 259 | */ |
260 | 260 | function give_reports_donors_table() { |
261 | - include( dirname( __FILE__ ) . '/class-donor-reports-table.php' ); |
|
261 | + include(dirname(__FILE__).'/class-donor-reports-table.php'); |
|
262 | 262 | |
263 | 263 | $give_table = new Give_Donor_Reports_Table(); |
264 | 264 | $give_table->prepare_items(); |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @since 1.0 |
272 | 272 | */ |
273 | - do_action( 'give_logs_donors_table_top' ); |
|
273 | + do_action('give_logs_donors_table_top'); |
|
274 | 274 | ?> |
275 | 275 | <form id="give-donors-filter" method="get"> |
276 | 276 | <?php |
277 | - $give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' ); |
|
277 | + $give_table->search_box(esc_html__('Search', 'give'), 'give-donors'); |
|
278 | 278 | $give_table->display(); |
279 | 279 | ?> |
280 | 280 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @since 1.0 |
289 | 289 | */ |
290 | - do_action( 'give_logs_donors_table_bottom' ); |
|
290 | + do_action('give_logs_donors_table_bottom'); |
|
291 | 291 | ?> |
292 | 292 | </div> |
293 | 293 | <?php |
294 | 294 | } |
295 | 295 | |
296 | -add_action( 'give_reports_view_donors', 'give_reports_donors_table' ); |
|
296 | +add_action('give_reports_view_donors', 'give_reports_donors_table'); |
|
297 | 297 | |
298 | 298 | |
299 | 299 | /** |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | * @return void |
306 | 306 | */ |
307 | 307 | function give_reports_gateways_table() { |
308 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' ); |
|
308 | + include(dirname(__FILE__).'/class-gateways-reports-table.php'); |
|
309 | 309 | |
310 | 310 | $give_table = new Give_Gateway_Reports_Table(); |
311 | 311 | $give_table->prepare_items(); |
312 | 312 | $give_table->display(); |
313 | 313 | } |
314 | 314 | |
315 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' ); |
|
315 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); |
|
316 | 316 | |
317 | 317 | |
318 | 318 | /** |
@@ -324,13 +324,13 @@ discard block |
||
324 | 324 | function give_reports_earnings() { |
325 | 325 | ?> |
326 | 326 | <div class="tablenav top reports-table-nav"> |
327 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Report', 'give' ); ?></span></h3> |
|
327 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Report', 'give'); ?></span></h3> |
|
328 | 328 | </div> |
329 | 329 | <?php |
330 | 330 | give_reports_graph(); |
331 | 331 | } |
332 | 332 | |
333 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' ); |
|
333 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); |
|
334 | 334 | |
335 | 335 | |
336 | 336 | /** |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function give_estimated_monthly_stats() { |
343 | 343 | |
344 | - $estimated = Give_Cache::get( 'give_estimated_monthly_stats', true ); |
|
344 | + $estimated = Give_Cache::get('give_estimated_monthly_stats', true); |
|
345 | 345 | |
346 | - if ( false === $estimated ) { |
|
346 | + if (false === $estimated) { |
|
347 | 347 | |
348 | 348 | $estimated = array( |
349 | 349 | 'earnings' => 0, |
@@ -352,22 +352,22 @@ discard block |
||
352 | 352 | |
353 | 353 | $stats = new Give_Payment_Stats; |
354 | 354 | |
355 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' ); |
|
356 | - $to_date_sales = $stats->get_sales( 0, 'this_month' ); |
|
355 | + $to_date_earnings = $stats->get_earnings(0, 'this_month'); |
|
356 | + $to_date_sales = $stats->get_sales(0, 'this_month'); |
|
357 | 357 | |
358 | - $current_day = date( 'd', current_time( 'timestamp' ) ); |
|
359 | - $current_month = date( 'n', current_time( 'timestamp' ) ); |
|
360 | - $current_year = date( 'Y', current_time( 'timestamp' ) ); |
|
361 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year ); |
|
358 | + $current_day = date('d', current_time('timestamp')); |
|
359 | + $current_month = date('n', current_time('timestamp')); |
|
360 | + $current_year = date('Y', current_time('timestamp')); |
|
361 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); |
|
362 | 362 | |
363 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month; |
|
364 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month; |
|
363 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month; |
|
364 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month; |
|
365 | 365 | |
366 | 366 | // Cache for one day |
367 | - Give_Cache::set( 'give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true ); |
|
367 | + Give_Cache::set('give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true); |
|
368 | 368 | } |
369 | 369 | |
370 | - return maybe_unserialize( $estimated ); |
|
370 | + return maybe_unserialize($estimated); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file. |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | * @param array $_data |
82 | 82 | * @param array $options |
83 | 83 | */ |
84 | - public function __construct( $_data, $options = array() ) { |
|
84 | + public function __construct($_data, $options = array()) { |
|
85 | 85 | |
86 | - $this->data = $_data; |
|
86 | + $this->data = $_data; |
|
87 | 87 | |
88 | 88 | // Generate unique ID |
89 | - $this->id = md5( rand() ); |
|
89 | + $this->id = md5(rand()); |
|
90 | 90 | |
91 | 91 | // Setup default options; |
92 | - $this->options = apply_filters( 'give_graph_args', array( |
|
92 | + $this->options = apply_filters('give_graph_args', array( |
|
93 | 93 | 'y_mode' => null, |
94 | 94 | 'x_mode' => null, |
95 | 95 | 'y_decimals' => 0, |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | 'lines' => false, |
108 | 108 | 'points' => true, |
109 | 109 | 'dataType' => array() |
110 | - ) ); |
|
110 | + )); |
|
111 | 111 | |
112 | - $this->options = wp_parse_args( $options, $this->options ); |
|
112 | + $this->options = wp_parse_args($options, $this->options); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @since 1.0 |
122 | 122 | */ |
123 | - public function set( $key, $value ) { |
|
124 | - $this->options[ $key ] = $value; |
|
123 | + public function set($key, $value) { |
|
124 | + $this->options[$key] = $value; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @since 1.0 |
133 | 133 | */ |
134 | - public function get( $key ) { |
|
135 | - return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false; |
|
134 | + public function get($key) { |
|
135 | + return isset($this->options[$key]) ? $this->options[$key] : false; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @since 1.0 |
142 | 142 | */ |
143 | 143 | public function get_data() { |
144 | - return apply_filters( 'give_get_graph_data', $this->data, $this ); |
|
144 | + return apply_filters('give_get_graph_data', $this->data, $this); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function load_scripts() { |
153 | 153 | // Use minified libraries if SCRIPT_DEBUG is turned off |
154 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
154 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
155 | 155 | |
156 | - wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
157 | - wp_enqueue_script( 'jquery-flot-orderbars' ); |
|
156 | + wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
157 | + wp_enqueue_script('jquery-flot-orderbars'); |
|
158 | 158 | |
159 | - wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
160 | - wp_enqueue_script( 'jquery-flot-time' ); |
|
159 | + wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
160 | + wp_enqueue_script('jquery-flot-time'); |
|
161 | 161 | |
162 | - wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
163 | - wp_enqueue_script( 'jquery-flot-resize' ); |
|
162 | + wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
163 | + wp_enqueue_script('jquery-flot-resize'); |
|
164 | 164 | |
165 | - wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION ); |
|
166 | - wp_enqueue_script( 'jquery-flot' ); |
|
165 | + wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION); |
|
166 | + wp_enqueue_script('jquery-flot'); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | [ |
191 | 191 | <?php |
192 | 192 | $order = 0; |
193 | - foreach( $this->get_data() as $label => $data ) : |
|
193 | + foreach ($this->get_data() as $label => $data) : |
|
194 | 194 | ?> |
195 | 195 | { |
196 | - label : "<?php echo esc_attr( $label ); ?>", |
|
197 | - id : "<?php echo sanitize_key( $label ); ?>", |
|
198 | - dataType : '<?php echo ( ! empty( $this->options['dataType'][$order] ) ? $this->options['dataType'][$order] : 'count' ); ?>', |
|
196 | + label : "<?php echo esc_attr($label); ?>", |
|
197 | + id : "<?php echo sanitize_key($label); ?>", |
|
198 | + dataType : '<?php echo ( ! empty($this->options['dataType'][$order]) ? $this->options['dataType'][$order] : 'count'); ?>', |
|
199 | 199 | // data format is: [ point on x, value on y ] |
200 | - data : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>], |
|
200 | + data : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>], |
|
201 | 201 | points: { |
202 | 202 | show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>, |
203 | 203 | }, |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | fill : true, |
213 | 213 | fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]} |
214 | 214 | }, |
215 | - <?php if( $this->options[ 'multiple_y_axes' ] ) : ?> |
|
215 | + <?php if ($this->options['multiple_y_axes']) : ?> |
|
216 | 216 | yaxis : <?php echo $yaxis_count; ?> |
217 | 217 | <?php endif; ?> |
218 | 218 | |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | grid: { |
227 | 227 | show : true, |
228 | 228 | aboveData : false, |
229 | - color : "<?php echo $this->options[ 'color' ]; ?>", |
|
230 | - backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>", |
|
231 | - borderColor : "<?php echo $this->options[ 'bordercolor' ]; ?>", |
|
232 | - borderWidth : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>, |
|
229 | + color : "<?php echo $this->options['color']; ?>", |
|
230 | + backgroundColor: "<?php echo $this->options['bgcolor']; ?>", |
|
231 | + borderColor : "<?php echo $this->options['bordercolor']; ?>", |
|
232 | + borderWidth : <?php echo absint($this->options['borderwidth']); ?>, |
|
233 | 233 | clickable : false, |
234 | 234 | hoverable : true |
235 | 235 | }, |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | mode : "<?php echo $this->options['x_mode']; ?>", |
241 | 241 | timeFormat : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
242 | 242 | tickSize : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>", |
243 | - <?php if( $this->options['x_mode'] != 'time' ) : ?> |
|
243 | + <?php if ($this->options['x_mode'] != 'time') : ?> |
|
244 | 244 | tickDecimals: <?php echo $this->options['x_decimals']; ?> |
245 | 245 | <?php endif; ?> |
246 | 246 | }, |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | min : 0, |
250 | 250 | mode : "<?php echo $this->options['y_mode']; ?>", |
251 | 251 | timeFormat : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
252 | - <?php if( $this->options['y_mode'] != 'time' ) : ?> |
|
252 | + <?php if ($this->options['y_mode'] != 'time') : ?> |
|
253 | 253 | tickDecimals: <?php echo $this->options['y_decimals']; ?> |
254 | 254 | <?php endif; ?> |
255 | 255 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @param Give_Graph $this Graph object. |
322 | 322 | */ |
323 | - do_action( 'give_before_graph', $this ); |
|
323 | + do_action('give_before_graph', $this); |
|
324 | 324 | |
325 | 325 | // Build the graph. |
326 | 326 | echo $this->build_graph(); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param Give_Graph $this Graph object. |
334 | 334 | */ |
335 | - do_action( 'give_after_graph', $this ); |
|
335 | + do_action('give_after_graph', $this); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly. |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | * 'testing' => false, // (required) Never leave as "true" in production!!! |
33 | 33 | * } |
34 | 34 | */ |
35 | - function __construct( $_banner_details ) { |
|
35 | + function __construct($_banner_details) { |
|
36 | 36 | $current_user = wp_get_current_user(); |
37 | 37 | |
38 | 38 | $this->plugin_activate_by = 0; |
39 | 39 | $this->banner_details = $_banner_details; |
40 | - $this->test_mode = ( $this->banner_details['testing'] == 'true' ) ? true : false; |
|
41 | - $this->nag_meta_key = 'give_addon_activation_ignore_' . sanitize_title( $this->banner_details['name'] ); |
|
42 | - $this->activate_by_meta_key = 'give_addon_' . sanitize_title( $this->banner_details['name'] ) . '_active_by_user'; |
|
40 | + $this->test_mode = ($this->banner_details['testing'] == 'true') ? true : false; |
|
41 | + $this->nag_meta_key = 'give_addon_activation_ignore_'.sanitize_title($this->banner_details['name']); |
|
42 | + $this->activate_by_meta_key = 'give_addon_'.sanitize_title($this->banner_details['name']).'_active_by_user'; |
|
43 | 43 | |
44 | 44 | //Get current user |
45 | 45 | $this->user_id = $current_user->ID; |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | public function init() { |
63 | 63 | |
64 | 64 | //Testing? |
65 | - if ( $this->test_mode ) { |
|
66 | - delete_user_meta( $this->user_id, $this->nag_meta_key ); |
|
65 | + if ($this->test_mode) { |
|
66 | + delete_user_meta($this->user_id, $this->nag_meta_key); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | //Get the current page to add the notice to |
70 | - add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) ); |
|
71 | - add_action( 'admin_notices', array( $this, 'give_addon_activation_admin_notice' ) ); |
|
70 | + add_action('current_screen', array($this, 'give_addon_notice_ignore')); |
|
71 | + add_action('admin_notices', array($this, 'give_addon_activation_admin_notice')); |
|
72 | 72 | |
73 | 73 | // File path of addon must be included in banner detail other addon activate meta will not delete. |
74 | 74 | $file_name = $this->get_plugin_file_name(); |
75 | 75 | |
76 | - if ( ! empty( $file_name ) ) { |
|
77 | - add_action( 'deactivate_' . $file_name, array( $this, 'remove_addon_activate_meta' ) ); |
|
76 | + if ( ! empty($file_name)) { |
|
77 | + add_action('deactivate_'.$file_name, array($this, 'remove_addon_activate_meta')); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | private function is_plugin_page() { |
90 | 90 | $screen = get_current_screen(); |
91 | 91 | |
92 | - return ( $screen->parent_file === 'plugins.php' ); |
|
92 | + return ($screen->parent_file === 'plugins.php'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | public function give_addon_activation_admin_notice() { |
103 | 103 | |
104 | 104 | // Bailout. |
105 | - if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by ) { |
|
105 | + if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | // If the user hasn't already dismissed the alert, output activation banner. |
110 | - if ( ! get_user_meta( $this->user_id, $this->nag_meta_key ) ) { |
|
110 | + if ( ! get_user_meta($this->user_id, $this->nag_meta_key)) { |
|
111 | 111 | |
112 | 112 | // Output inline styles here because there's no reason |
113 | 113 | // to enqueued them after the alert is dismissed. |
@@ -189,44 +189,44 @@ discard block |
||
189 | 189 | <h3><?php |
190 | 190 | printf( |
191 | 191 | /* translators: %s: Add-on name */ |
192 | - esc_html__( "Thank you for installing Give's %s Add-on!", 'give' ), |
|
193 | - '<span>' . $this->banner_details['name'] . '</span>' |
|
192 | + esc_html__("Thank you for installing Give's %s Add-on!", 'give'), |
|
193 | + '<span>'.$this->banner_details['name'].'</span>' |
|
194 | 194 | ); |
195 | 195 | ?></h3> |
196 | 196 | |
197 | 197 | <a href="<?php |
198 | 198 | //The Dismiss Button. |
199 | - $nag_admin_dismiss_url = 'plugins.php?' . $this->nag_meta_key . '=0'; |
|
200 | - echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss"><span |
|
199 | + $nag_admin_dismiss_url = 'plugins.php?'.$this->nag_meta_key.'=0'; |
|
200 | + echo admin_url($nag_admin_dismiss_url); ?>" class="dismiss"><span |
|
201 | 201 | class="dashicons dashicons-dismiss"></span></a> |
202 | 202 | |
203 | 203 | <div class="alert-actions"> |
204 | 204 | |
205 | 205 | <?php //Point them to your settings page. |
206 | - if ( isset( $this->banner_details['settings_url'] ) ) { ?> |
|
206 | + if (isset($this->banner_details['settings_url'])) { ?> |
|
207 | 207 | <a href="<?php echo $this->banner_details['settings_url']; ?>"> |
208 | - <span class="dashicons dashicons-admin-settings"></span><?php esc_html_e( 'Go to Settings', 'give' ); ?> |
|
208 | + <span class="dashicons dashicons-admin-settings"></span><?php esc_html_e('Go to Settings', 'give'); ?> |
|
209 | 209 | </a> |
210 | 210 | <?php } ?> |
211 | 211 | |
212 | 212 | <?php |
213 | 213 | // Show them how to configure the Addon. |
214 | - if ( isset( $this->banner_details['documentation_url'] ) ) { ?> |
|
214 | + if (isset($this->banner_details['documentation_url'])) { ?> |
|
215 | 215 | <a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank"> |
216 | 216 | <span class="dashicons dashicons-media-text"></span><?php |
217 | 217 | printf( |
218 | 218 | /* translators: %s: Add-on name */ |
219 | - esc_html__( 'Documentation: %s Add-on', 'give' ), |
|
219 | + esc_html__('Documentation: %s Add-on', 'give'), |
|
220 | 220 | $this->banner_details['name'] |
221 | 221 | ); |
222 | 222 | ?></a> |
223 | 223 | <?php } ?> |
224 | 224 | <?php |
225 | 225 | //Let them signup for plugin updates |
226 | - if ( isset( $this->banner_details['support_url'] ) ) { ?> |
|
226 | + if (isset($this->banner_details['support_url'])) { ?> |
|
227 | 227 | |
228 | 228 | <a href="<?php echo $this->banner_details['support_url'] ?>" target="_blank"> |
229 | - <span class="dashicons dashicons-sos"></span><?php esc_html_e( 'Get Support', 'give' ); ?> |
|
229 | + <span class="dashicons dashicons-sos"></span><?php esc_html_e('Get Support', 'give'); ?> |
|
230 | 230 | </a> |
231 | 231 | |
232 | 232 | <?php } ?> |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | * If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not. |
254 | 254 | * See here: http://codex.wordpress.org/Function_Reference/add_user_meta |
255 | 255 | */ |
256 | - if ( isset( $_GET[ $this->nag_meta_key ] ) && '0' == $_GET[ $this->nag_meta_key ] ) { |
|
256 | + if (isset($_GET[$this->nag_meta_key]) && '0' == $_GET[$this->nag_meta_key]) { |
|
257 | 257 | |
258 | 258 | //Get the global user |
259 | 259 | $current_user = wp_get_current_user(); |
260 | 260 | $user_id = $current_user->ID; |
261 | 261 | |
262 | - add_user_meta( $user_id, $this->nag_meta_key, 'true', true ); |
|
262 | + add_user_meta($user_id, $this->nag_meta_key, 'true', true); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | * @access private |
271 | 271 | */ |
272 | 272 | private function add_addon_activate_meta() { |
273 | - $user_id = get_option( $this->activate_by_meta_key ); |
|
273 | + $user_id = get_option($this->activate_by_meta_key); |
|
274 | 274 | $this->plugin_activate_by = (int) $user_id; |
275 | 275 | |
276 | - if ( ! $user_id ) { |
|
277 | - add_option( $this->activate_by_meta_key, $this->user_id, '', 'no' ); |
|
276 | + if ( ! $user_id) { |
|
277 | + add_option($this->activate_by_meta_key, $this->user_id, '', 'no'); |
|
278 | 278 | $this->plugin_activate_by = (int) $this->user_id; |
279 | 279 | } |
280 | 280 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * @access public |
288 | 288 | */ |
289 | 289 | public function remove_addon_activate_meta() { |
290 | - $user_id = get_option( $this->activate_by_meta_key ); |
|
290 | + $user_id = get_option($this->activate_by_meta_key); |
|
291 | 291 | |
292 | - if ( $user_id ) { |
|
293 | - delete_option( $this->activate_by_meta_key ); |
|
292 | + if ($user_id) { |
|
293 | + delete_option($this->activate_by_meta_key); |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | |
@@ -303,39 +303,39 @@ discard block |
||
303 | 303 | * @return mixed |
304 | 304 | */ |
305 | 305 | private function get_plugin_file_name() { |
306 | - $active_plugins = get_option( 'active_plugins' ); |
|
306 | + $active_plugins = get_option('active_plugins'); |
|
307 | 307 | $file_name = ''; |
308 | 308 | |
309 | 309 | try { |
310 | 310 | |
311 | 311 | // Check addon file path. |
312 | - if ( ! empty( $this->banner_details['file'] ) ) { |
|
312 | + if ( ! empty($this->banner_details['file'])) { |
|
313 | 313 | $file_name = ''; |
314 | - if ( $file_path = explode( '/plugins/', $this->banner_details['file'] ) ) { |
|
315 | - $file_path = array_pop( $file_path ); |
|
316 | - $file_name = current( explode( '/', $file_path ) ); |
|
314 | + if ($file_path = explode('/plugins/', $this->banner_details['file'])) { |
|
315 | + $file_path = array_pop($file_path); |
|
316 | + $file_name = current(explode('/', $file_path)); |
|
317 | 317 | } |
318 | 318 | |
319 | - if ( empty( $file_name ) ) { |
|
319 | + if (empty($file_name)) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | - foreach ( $active_plugins as $plugin ) { |
|
324 | - if ( false !== strpos( $plugin, $file_name ) ) { |
|
323 | + foreach ($active_plugins as $plugin) { |
|
324 | + if (false !== strpos($plugin, $file_name)) { |
|
325 | 325 | $file_name = $plugin; |
326 | 326 | break; |
327 | 327 | } |
328 | 328 | } |
329 | - } elseif ( WP_DEBUG ) { |
|
330 | - throw new Exception( __( "File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give' ) ); |
|
329 | + } elseif (WP_DEBUG) { |
|
330 | + throw new Exception(__("File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give')); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | // Check plugin path calculated by addon file path. |
334 | - if ( empty( $file_name ) && WP_DEBUG ) { |
|
335 | - throw new Exception( __( "Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give' ) ); |
|
334 | + if (empty($file_name) && WP_DEBUG) { |
|
335 | + throw new Exception(__("Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give')); |
|
336 | 336 | } |
337 | 337 | |
338 | - } catch ( Exception $e ) { |
|
338 | + } catch (Exception $e) { |
|
339 | 339 | echo $e->getMessage(); |
340 | 340 | } |
341 | 341 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare( $give_version, '1.8.8', '<' ) : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
@@ -909,19 +909,19 @@ discard block |
||
909 | 909 | |
910 | 910 | global $wp_roles; |
911 | 911 | |
912 | - // Get the role object. |
|
913 | - $give_worker = get_role( 'give_worker' ); |
|
912 | + // Get the role object. |
|
913 | + $give_worker = get_role( 'give_worker' ); |
|
914 | 914 | |
915 | 915 | // A list of capabilities to add for give workers. |
916 | - $caps_to_add = array( |
|
917 | - 'edit_posts', |
|
918 | - 'edit_pages' |
|
919 | - ); |
|
920 | - |
|
921 | - foreach ( $caps_to_add as $cap ) { |
|
922 | - // Add the capability. |
|
923 | - $give_worker->add_cap( $cap ); |
|
924 | - } |
|
916 | + $caps_to_add = array( |
|
917 | + 'edit_posts', |
|
918 | + 'edit_pages' |
|
919 | + ); |
|
920 | + |
|
921 | + foreach ( $caps_to_add as $cap ) { |
|
922 | + // Add the capability. |
|
923 | + $give_worker->add_cap( $cap ); |
|
924 | + } |
|
925 | 925 | |
926 | 926 | } |
927 | 927 |
@@ -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 | |
@@ -25,44 +25,44 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | 57 | } |
58 | 58 | |
59 | - if ( $did_upgrade ) { |
|
60 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
59 | + if ($did_upgrade) { |
|
60 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
65 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
64 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
65 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Display Upgrade Notices |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function give_show_upgrade_notices() { |
74 | 74 | // Don't show notices on the upgrades page. |
75 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
75 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | - $give_version = get_option( 'give_version' ); |
|
79 | + $give_version = get_option('give_version'); |
|
80 | 80 | |
81 | - if ( ! $give_version ) { |
|
81 | + if ( ! $give_version) { |
|
82 | 82 | // 1.0 is the first version to use this option so we must add it. |
83 | 83 | $give_version = '1.0'; |
84 | 84 | } |
85 | 85 | |
86 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
86 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
87 | 87 | |
88 | 88 | /* |
89 | 89 | * NOTICE: |
@@ -94,31 +94,31 @@ discard block |
||
94 | 94 | */ |
95 | 95 | |
96 | 96 | // v1.3.2 Upgrades |
97 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
97 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
98 | 98 | printf( |
99 | 99 | /* translators: %s: upgrade URL */ |
100 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
101 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
100 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
101 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | 105 | // v1.3.4 Upgrades //ensure the user has gone through 1.3.4. |
106 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
106 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
107 | 107 | printf( |
108 | 108 | /* translators: %s: upgrade URL */ |
109 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
110 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
109 | + '<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
110 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
111 | 111 | ); |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Check if we have a stalled upgrade. |
115 | 115 | $resume_upgrade = give_maybe_resume_upgrade(); |
116 | - if ( ! empty( $resume_upgrade ) ) { |
|
117 | - $resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) ); |
|
116 | + if ( ! empty($resume_upgrade)) { |
|
117 | + $resume_url = add_query_arg($resume_upgrade, admin_url('index.php')); |
|
118 | 118 | echo Give_Notices::notice_html( |
119 | 119 | sprintf( |
120 | - __( 'Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give' ), |
|
121 | - esc_url( $resume_url ) |
|
120 | + __('Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give'), |
|
121 | + esc_url($resume_url) |
|
122 | 122 | ) |
123 | 123 | ); |
124 | 124 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // v1.8 form metadata upgrades. |
129 | - if ( version_compare( $give_version, '1.8', '<' ) || ! give_has_upgrade_completed( 'v18_upgrades_form_metadata' ) ) { |
|
129 | + if (version_compare($give_version, '1.8', '<') || ! give_has_upgrade_completed('v18_upgrades_form_metadata')) { |
|
130 | 130 | echo Give_Notices::notice_html( |
131 | 131 | sprintf( |
132 | - esc_html__( 'Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give' ), |
|
133 | - '<a class="give-upgrade-link" href="' . esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata' ) ) . '">', |
|
132 | + esc_html__('Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give'), |
|
133 | + '<a class="give-upgrade-link" href="'.esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata')).'">', |
|
134 | 134 | '</a>' |
135 | 135 | ) |
136 | 136 | ); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $upgrade_links.on( 'click', function(e){ |
146 | 146 | e.preventDefault(); |
147 | 147 | |
148 | - if( ! window.confirm( '<?php _e( 'Please make sure to create a database backup before initiating the upgrade.', 'give' ); ?>' ) ) { |
|
148 | + if( ! window.confirm( '<?php _e('Please make sure to create a database backup before initiating the upgrade.', 'give'); ?>' ) ) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | <?php |
159 | 159 | } |
160 | 160 | |
161 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
161 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Triggers all upgrade functions |
@@ -170,29 +170,29 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function give_trigger_upgrades() { |
172 | 172 | |
173 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
174 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
173 | + if ( ! current_user_can('manage_give_settings')) { |
|
174 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
175 | 175 | 'response' => 403, |
176 | - ) ); |
|
176 | + )); |
|
177 | 177 | } |
178 | 178 | |
179 | - $give_version = get_option( 'give_version' ); |
|
179 | + $give_version = get_option('give_version'); |
|
180 | 180 | |
181 | - if ( ! $give_version ) { |
|
181 | + if ( ! $give_version) { |
|
182 | 182 | // 1.0 is the first version to use this option so we must add it. |
183 | 183 | $give_version = '1.0'; |
184 | - add_option( 'give_version', $give_version ); |
|
184 | + add_option('give_version', $give_version); |
|
185 | 185 | } |
186 | 186 | |
187 | - update_option( 'give_version', GIVE_VERSION ); |
|
188 | - delete_option( 'give_doing_upgrade' ); |
|
187 | + update_option('give_version', GIVE_VERSION); |
|
188 | + delete_option('give_doing_upgrade'); |
|
189 | 189 | |
190 | - if ( DOING_AJAX ) { |
|
191 | - die( 'complete' ); |
|
190 | + if (DOING_AJAX) { |
|
191 | + die('complete'); |
|
192 | 192 | } // End if(). |
193 | 193 | } |
194 | 194 | |
195 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
195 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Check if the upgrade routine has been run for a specific action |
@@ -203,15 +203,15 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return bool If the action has been added to the completed actions array |
205 | 205 | */ |
206 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
206 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
207 | 207 | |
208 | - if ( empty( $upgrade_action ) ) { |
|
208 | + if (empty($upgrade_action)) { |
|
209 | 209 | return false; |
210 | 210 | } |
211 | 211 | |
212 | 212 | $completed_upgrades = give_get_completed_upgrades(); |
213 | 213 | |
214 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
214 | + return in_array($upgrade_action, $completed_upgrades); |
|
215 | 215 | |
216 | 216 | } |
217 | 217 | |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
224 | 224 | */ |
225 | 225 | function give_maybe_resume_upgrade() { |
226 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
227 | - if ( empty( $doing_upgrade ) ) { |
|
226 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
227 | + if (empty($doing_upgrade)) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return bool If the function was successfully added |
242 | 242 | */ |
243 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
243 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
244 | 244 | |
245 | - if ( empty( $upgrade_action ) ) { |
|
245 | + if (empty($upgrade_action)) { |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | $completed_upgrades[] = $upgrade_action; |
251 | 251 | |
252 | 252 | // Remove any blanks, and only show uniques. |
253 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
253 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
254 | 254 | |
255 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
255 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | */ |
264 | 264 | function give_get_completed_upgrades() { |
265 | 265 | |
266 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
266 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
267 | 267 | |
268 | - if ( false === $completed_upgrades ) { |
|
268 | + if (false === $completed_upgrades) { |
|
269 | 269 | $completed_upgrades = array(); |
270 | 270 | } |
271 | 271 | |
@@ -282,31 +282,31 @@ discard block |
||
282 | 282 | */ |
283 | 283 | function give_v132_upgrade_give_payment_customer_id() { |
284 | 284 | global $wpdb; |
285 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
286 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
285 | + if ( ! current_user_can('manage_give_settings')) { |
|
286 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
287 | 287 | 'response' => 403, |
288 | - ) ); |
|
288 | + )); |
|
289 | 289 | } |
290 | 290 | |
291 | - ignore_user_abort( true ); |
|
291 | + ignore_user_abort(true); |
|
292 | 292 | |
293 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
294 | - @set_time_limit( 0 ); |
|
293 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
294 | + @set_time_limit(0); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | // UPDATE DB METAKEYS. |
298 | 298 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
299 | - $query = $wpdb->query( $sql ); |
|
299 | + $query = $wpdb->query($sql); |
|
300 | 300 | |
301 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
302 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
303 | - delete_option( 'give_doing_upgrade' ); |
|
304 | - wp_redirect( admin_url() ); |
|
301 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
302 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
303 | + delete_option('give_doing_upgrade'); |
|
304 | + wp_redirect(admin_url()); |
|
305 | 305 | exit; |
306 | 306 | |
307 | 307 | } |
308 | 308 | |
309 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
309 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Upgrades the Offline Status |
@@ -319,16 +319,16 @@ discard block |
||
319 | 319 | |
320 | 320 | global $wpdb; |
321 | 321 | |
322 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
323 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
322 | + if ( ! current_user_can('manage_give_settings')) { |
|
323 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
324 | 324 | 'response' => 403, |
325 | - ) ); |
|
325 | + )); |
|
326 | 326 | } |
327 | 327 | |
328 | - ignore_user_abort( true ); |
|
328 | + ignore_user_abort(true); |
|
329 | 329 | |
330 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
331 | - @set_time_limit( 0 ); |
|
330 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
331 | + @set_time_limit(0); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | // Get abandoned offline payments. |
@@ -338,31 +338,31 @@ discard block |
||
338 | 338 | $where .= "AND ( p.post_status = 'abandoned' )"; |
339 | 339 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
340 | 340 | |
341 | - $sql = $select . $join . $where; |
|
342 | - $found_payments = $wpdb->get_col( $sql ); |
|
341 | + $sql = $select.$join.$where; |
|
342 | + $found_payments = $wpdb->get_col($sql); |
|
343 | 343 | |
344 | - foreach ( $found_payments as $payment ) { |
|
344 | + foreach ($found_payments as $payment) { |
|
345 | 345 | |
346 | 346 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
347 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
347 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
348 | 348 | |
349 | 349 | // 1450124863 = 12/10/2015 20:42:25. |
350 | - if ( $modified_time >= 1450124863 ) { |
|
350 | + if ($modified_time >= 1450124863) { |
|
351 | 351 | |
352 | - give_update_payment_status( $payment, 'pending' ); |
|
352 | + give_update_payment_status($payment, 'pending'); |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
358 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
359 | - delete_option( 'give_doing_upgrade' ); |
|
360 | - wp_redirect( admin_url() ); |
|
357 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
358 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
359 | + delete_option('give_doing_upgrade'); |
|
360 | + wp_redirect(admin_url()); |
|
361 | 361 | exit; |
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
365 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
366 | 366 | |
367 | 367 | /** |
368 | 368 | * Cleanup User Roles |
@@ -373,17 +373,17 @@ discard block |
||
373 | 373 | */ |
374 | 374 | function give_v152_cleanup_users() { |
375 | 375 | |
376 | - $give_version = get_option( 'give_version' ); |
|
376 | + $give_version = get_option('give_version'); |
|
377 | 377 | |
378 | - if ( ! $give_version ) { |
|
378 | + if ( ! $give_version) { |
|
379 | 379 | // 1.0 is the first version to use this option so we must add it. |
380 | 380 | $give_version = '1.0'; |
381 | 381 | } |
382 | 382 | |
383 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
383 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
384 | 384 | |
385 | 385 | // v1.5.2 Upgrades |
386 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
386 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
387 | 387 | |
388 | 388 | // Delete all caps with "ss". |
389 | 389 | // Also delete all unused "campaign" roles. |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | ); |
431 | 431 | |
432 | 432 | global $wp_roles; |
433 | - foreach ( $delete_caps as $cap ) { |
|
434 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
435 | - $wp_roles->remove_cap( $role, $cap ); |
|
433 | + foreach ($delete_caps as $cap) { |
|
434 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
435 | + $wp_roles->remove_cap($role, $cap); |
|
436 | 436 | } |
437 | 437 | } |
438 | 438 | |
@@ -442,15 +442,15 @@ discard block |
||
442 | 442 | $roles->add_caps(); |
443 | 443 | |
444 | 444 | // The Update Ran. |
445 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
446 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
447 | - delete_option( 'give_doing_upgrade' ); |
|
445 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
446 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
447 | + delete_option('give_doing_upgrade'); |
|
448 | 448 | |
449 | 449 | }// End if(). |
450 | 450 | |
451 | 451 | } |
452 | 452 | |
453 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
453 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
454 | 454 | |
455 | 455 | /** |
456 | 456 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -490,53 +490,53 @@ discard block |
||
490 | 490 | |
491 | 491 | // Get addons license key. |
492 | 492 | $addons = array(); |
493 | - foreach ( $give_options as $key => $value ) { |
|
494 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
495 | - $addons[ $key ] = $value; |
|
493 | + foreach ($give_options as $key => $value) { |
|
494 | + if (false !== strpos($key, '_license_key')) { |
|
495 | + $addons[$key] = $value; |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | |
499 | 499 | // Bailout: We do not have any addon license data to upgrade. |
500 | - if ( empty( $addons ) ) { |
|
500 | + if (empty($addons)) { |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | |
504 | - foreach ( $addons as $key => $addon_license ) { |
|
504 | + foreach ($addons as $key => $addon_license) { |
|
505 | 505 | |
506 | 506 | // Get addon shortname. |
507 | - $shortname = str_replace( '_license_key', '', $key ); |
|
507 | + $shortname = str_replace('_license_key', '', $key); |
|
508 | 508 | |
509 | 509 | // Addon license option name. |
510 | - $addon_license_option_name = $shortname . '_license_active'; |
|
510 | + $addon_license_option_name = $shortname.'_license_active'; |
|
511 | 511 | |
512 | 512 | // bailout if license is empty. |
513 | - if ( empty( $addon_license ) ) { |
|
514 | - delete_option( $addon_license_option_name ); |
|
513 | + if (empty($addon_license)) { |
|
514 | + delete_option($addon_license_option_name); |
|
515 | 515 | continue; |
516 | 516 | } |
517 | 517 | |
518 | 518 | // Get addon name. |
519 | 519 | $addon_name = array(); |
520 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
521 | - foreach ( $addon_name_parts as $name_part ) { |
|
520 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
521 | + foreach ($addon_name_parts as $name_part) { |
|
522 | 522 | |
523 | 523 | // Fix addon name |
524 | - switch ( $name_part ) { |
|
524 | + switch ($name_part) { |
|
525 | 525 | case 'authorizenet' : |
526 | 526 | $name_part = 'authorize.net'; |
527 | 527 | break; |
528 | 528 | } |
529 | 529 | |
530 | - $addon_name[] = ucfirst( $name_part ); |
|
530 | + $addon_name[] = ucfirst($name_part); |
|
531 | 531 | } |
532 | 532 | |
533 | - $addon_name = implode( ' ', $addon_name ); |
|
533 | + $addon_name = implode(' ', $addon_name); |
|
534 | 534 | |
535 | 535 | // Data to send to the API |
536 | 536 | $api_params = array( |
537 | 537 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
538 | 538 | 'license' => $addon_license, |
539 | - 'item_name' => urlencode( $addon_name ), |
|
539 | + 'item_name' => urlencode($addon_name), |
|
540 | 540 | 'url' => home_url(), |
541 | 541 | ); |
542 | 542 | |
@@ -551,17 +551,17 @@ discard block |
||
551 | 551 | ); |
552 | 552 | |
553 | 553 | // Make sure there are no errors. |
554 | - if ( is_wp_error( $response ) ) { |
|
555 | - delete_option( $addon_license_option_name ); |
|
554 | + if (is_wp_error($response)) { |
|
555 | + delete_option($addon_license_option_name); |
|
556 | 556 | continue; |
557 | 557 | } |
558 | 558 | |
559 | 559 | // Tell WordPress to look for updates. |
560 | - set_site_transient( 'update_plugins', null ); |
|
560 | + set_site_transient('update_plugins', null); |
|
561 | 561 | |
562 | 562 | // Decode license data. |
563 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
564 | - update_option( $addon_license_option_name, $license_data ); |
|
563 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
564 | + update_option($addon_license_option_name, $license_data); |
|
565 | 565 | }// End foreach(). |
566 | 566 | } |
567 | 567 | |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | ); |
592 | 592 | |
593 | 593 | global $wp_roles; |
594 | - foreach ( $delete_caps as $cap ) { |
|
595 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
596 | - $wp_roles->remove_cap( $role, $cap ); |
|
594 | + foreach ($delete_caps as $cap) { |
|
595 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
596 | + $wp_roles->remove_cap($role, $cap); |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | function give_v18_upgrades_core_setting() { |
628 | 628 | // Core settings which changes from checkbox to radio. |
629 | 629 | $core_setting_names = array_merge( |
630 | - array_keys( give_v18_renamed_core_settings() ), |
|
630 | + array_keys(give_v18_renamed_core_settings()), |
|
631 | 631 | array( |
632 | 632 | 'uninstall_on_delete', |
633 | 633 | 'scripts_footer', |
@@ -639,48 +639,48 @@ discard block |
||
639 | 639 | ); |
640 | 640 | |
641 | 641 | // Bailout: If not any setting define. |
642 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
642 | + if ($give_settings = get_option('give_settings')) { |
|
643 | 643 | |
644 | 644 | $setting_changed = false; |
645 | 645 | |
646 | 646 | // Loop: check each setting field. |
647 | - foreach ( $core_setting_names as $setting_name ) { |
|
647 | + foreach ($core_setting_names as $setting_name) { |
|
648 | 648 | // New setting name. |
649 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
649 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
650 | 650 | |
651 | 651 | // Continue: If setting already set. |
652 | 652 | if ( |
653 | - array_key_exists( $new_setting_name, $give_settings ) |
|
654 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
653 | + array_key_exists($new_setting_name, $give_settings) |
|
654 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
655 | 655 | ) { |
656 | 656 | continue; |
657 | 657 | } |
658 | 658 | |
659 | 659 | // Set checkbox value to radio value. |
660 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
660 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
661 | 661 | |
662 | 662 | // @see https://github.com/WordImpress/Give/issues/1063 |
663 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
663 | + if (false !== strpos($setting_name, 'disable_')) { |
|
664 | 664 | |
665 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
666 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
665 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
666 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
667 | 667 | |
668 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
668 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | // Tell bot to update core setting to db. |
672 | - if ( ! $setting_changed ) { |
|
672 | + if ( ! $setting_changed) { |
|
673 | 673 | $setting_changed = true; |
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
677 | 677 | // Update setting only if they changed. |
678 | - if ( $setting_changed ) { |
|
679 | - update_option( 'give_settings', $give_settings ); |
|
678 | + if ($setting_changed) { |
|
679 | + update_option('give_settings', $give_settings); |
|
680 | 680 | } |
681 | 681 | }// End if(). |
682 | 682 | |
683 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
683 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -690,22 +690,22 @@ discard block |
||
690 | 690 | * @return void |
691 | 691 | */ |
692 | 692 | function give_v18_upgrades_form_metadata() { |
693 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
694 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
693 | + if ( ! current_user_can('manage_give_settings')) { |
|
694 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
695 | 695 | 'response' => 403, |
696 | - ) ); |
|
696 | + )); |
|
697 | 697 | } |
698 | 698 | |
699 | - ignore_user_abort( true ); |
|
699 | + ignore_user_abort(true); |
|
700 | 700 | |
701 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
702 | - @set_time_limit( 0 ); |
|
701 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
702 | + @set_time_limit(0); |
|
703 | 703 | } |
704 | 704 | |
705 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
705 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
706 | 706 | |
707 | 707 | // form query |
708 | - $forms = new WP_Query( array( |
|
708 | + $forms = new WP_Query(array( |
|
709 | 709 | 'paged' => $step, |
710 | 710 | 'status' => 'any', |
711 | 711 | 'order' => 'ASC', |
@@ -714,39 +714,39 @@ discard block |
||
714 | 714 | ) |
715 | 715 | ); |
716 | 716 | |
717 | - if ( $forms->have_posts() ) { |
|
718 | - while ( $forms->have_posts() ) { |
|
717 | + if ($forms->have_posts()) { |
|
718 | + while ($forms->have_posts()) { |
|
719 | 719 | $forms->the_post(); |
720 | 720 | |
721 | 721 | // Form content. |
722 | 722 | // Note in version 1.8 display content setting split into display content and content placement setting. |
723 | 723 | // You can delete _give_content_option in future |
724 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
725 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
726 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
727 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
724 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
725 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
726 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
727 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
728 | 728 | |
729 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
730 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
729 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
730 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | // "Disable" Guest Donation. Checkbox |
734 | 734 | // See: https://github.com/WordImpress/Give/issues/1470 |
735 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
736 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
737 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
735 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
736 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
737 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
738 | 738 | |
739 | 739 | // Offline Donations |
740 | 740 | // See: https://github.com/WordImpress/Give/issues/1579 |
741 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
742 | - if ( 'no' === $offline_donation ) { |
|
741 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
742 | + if ('no' === $offline_donation) { |
|
743 | 743 | $offline_donation_newval = 'global'; |
744 | - } elseif ( 'yes' === $offline_donation ) { |
|
744 | + } elseif ('yes' === $offline_donation) { |
|
745 | 745 | $offline_donation_newval = 'enabled'; |
746 | 746 | } else { |
747 | 747 | $offline_donation_newval = 'disabled'; |
748 | 748 | } |
749 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
749 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
750 | 750 | |
751 | 751 | // Convert yes/no setting field to enabled/disabled. |
752 | 752 | $form_radio_settings = array( |
@@ -766,15 +766,15 @@ discard block |
||
766 | 766 | '_give_offline_donation_enable_billing_fields_single', |
767 | 767 | ); |
768 | 768 | |
769 | - foreach ( $form_radio_settings as $meta_key ) { |
|
769 | + foreach ($form_radio_settings as $meta_key) { |
|
770 | 770 | // Get value. |
771 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
771 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
772 | 772 | |
773 | 773 | // Convert meta value only if it is in yes/no/none. |
774 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
774 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
775 | 775 | |
776 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
777 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
776 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
777 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
778 | 778 | } |
779 | 779 | } |
780 | 780 | }// End while(). |
@@ -782,27 +782,27 @@ discard block |
||
782 | 782 | wp_reset_postdata(); |
783 | 783 | |
784 | 784 | // Forms found so upgrade them |
785 | - $step ++; |
|
786 | - $redirect = add_query_arg( array( |
|
785 | + $step++; |
|
786 | + $redirect = add_query_arg(array( |
|
787 | 787 | 'page' => 'give-upgrades', |
788 | 788 | 'give-upgrade' => 'give_v18_upgrades_form_metadata', |
789 | 789 | 'step' => $step, |
790 | - ), admin_url( 'index.php' ) ); |
|
791 | - wp_redirect( $redirect ); |
|
790 | + ), admin_url('index.php')); |
|
791 | + wp_redirect($redirect); |
|
792 | 792 | exit(); |
793 | 793 | |
794 | 794 | } else { |
795 | 795 | // No more forms found, finish up. |
796 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
797 | - delete_option( 'give_doing_upgrade' ); |
|
798 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
796 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
797 | + delete_option('give_doing_upgrade'); |
|
798 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
799 | 799 | |
800 | - wp_redirect( admin_url() ); |
|
800 | + wp_redirect(admin_url()); |
|
801 | 801 | exit; |
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
805 | -add_action( 'give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata' ); |
|
805 | +add_action('give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata'); |
|
806 | 806 | |
807 | 807 | /** |
808 | 808 | * Get list of core setting renamed in version 1.8. |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * @since 1.8.7 |
836 | 836 | * @return void |
837 | 837 | */ |
838 | -function give_v187_upgrades(){ |
|
838 | +function give_v187_upgrades() { |
|
839 | 839 | global $wpdb; |
840 | 840 | |
841 | 841 | /** |
@@ -875,24 +875,24 @@ discard block |
||
875 | 875 | ARRAY_A |
876 | 876 | ); |
877 | 877 | |
878 | - if( ! empty( $user_apikey_options ) ) { |
|
879 | - foreach ( $user_apikey_options as $user ) { |
|
880 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
881 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
882 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
878 | + if ( ! empty($user_apikey_options)) { |
|
879 | + foreach ($user_apikey_options as $user) { |
|
880 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
881 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
882 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
886 | - if ( ! empty( $cached_options ) ) { |
|
887 | - foreach ( $cached_options as $option ) { |
|
888 | - switch ( true ) { |
|
889 | - case ( false !== strpos( $option, 'transient' ) ): |
|
890 | - $option = str_replace( '_transient_', '', $option ); |
|
891 | - delete_transient( $option ); |
|
886 | + if ( ! empty($cached_options)) { |
|
887 | + foreach ($cached_options as $option) { |
|
888 | + switch (true) { |
|
889 | + case (false !== strpos($option, 'transient')): |
|
890 | + $option = str_replace('_transient_', '', $option); |
|
891 | + delete_transient($option); |
|
892 | 892 | break; |
893 | 893 | |
894 | 894 | default: |
895 | - delete_option( $option ); |
|
895 | + delete_option($option); |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | } |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | global $wp_roles; |
911 | 911 | |
912 | 912 | // Get the role object. |
913 | - $give_worker = get_role( 'give_worker' ); |
|
913 | + $give_worker = get_role('give_worker'); |
|
914 | 914 | |
915 | 915 | // A list of capabilities to add for give workers. |
916 | 916 | $caps_to_add = array( |
@@ -918,9 +918,9 @@ discard block |
||
918 | 918 | 'edit_pages' |
919 | 919 | ); |
920 | 920 | |
921 | - foreach ( $caps_to_add as $cap ) { |
|
921 | + foreach ($caps_to_add as $cap) { |
|
922 | 922 | // Add the capability. |
923 | - $give_worker->add_cap( $cap ); |
|
923 | + $give_worker->add_cap($cap); |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | } |
@@ -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 | |
@@ -27,34 +27,34 @@ discard block |
||
27 | 27 | * @return array $form_columns Updated array of forms columns |
28 | 28 | * Post Type List Table |
29 | 29 | */ |
30 | -function give_form_columns( $give_form_columns ) { |
|
30 | +function give_form_columns($give_form_columns) { |
|
31 | 31 | |
32 | 32 | // Standard columns |
33 | 33 | $give_form_columns = array( |
34 | 34 | 'cb' => '<input type="checkbox"/>', |
35 | - 'title' => esc_html__( 'Name', 'give' ), |
|
36 | - 'form_category' => esc_html__( 'Categories', 'give' ), |
|
37 | - 'form_tag' => esc_html__( 'Tags', 'give' ), |
|
38 | - 'price' => esc_html__( 'Amount', 'give' ), |
|
39 | - 'goal' => esc_html__( 'Goal', 'give' ), |
|
40 | - 'donations' => esc_html__( 'Donations', 'give' ), |
|
41 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
42 | - 'shortcode' => esc_html__( 'Shortcode', 'give' ), |
|
43 | - 'date' => esc_html__( 'Date', 'give' ), |
|
35 | + 'title' => esc_html__('Name', 'give'), |
|
36 | + 'form_category' => esc_html__('Categories', 'give'), |
|
37 | + 'form_tag' => esc_html__('Tags', 'give'), |
|
38 | + 'price' => esc_html__('Amount', 'give'), |
|
39 | + 'goal' => esc_html__('Goal', 'give'), |
|
40 | + 'donations' => esc_html__('Donations', 'give'), |
|
41 | + 'earnings' => esc_html__('Income', 'give'), |
|
42 | + 'shortcode' => esc_html__('Shortcode', 'give'), |
|
43 | + 'date' => esc_html__('Date', 'give'), |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | // Does the user want categories / tags? |
47 | - if ( ! give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
48 | - unset( $give_form_columns['form_category'] ); |
|
47 | + if ( ! give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
48 | + unset($give_form_columns['form_category']); |
|
49 | 49 | } |
50 | - if ( ! give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
51 | - unset( $give_form_columns['form_tag'] ); |
|
50 | + if ( ! give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
51 | + unset($give_form_columns['form_tag']); |
|
52 | 52 | } |
53 | 53 | |
54 | - return apply_filters( 'give_forms_columns', $give_form_columns ); |
|
54 | + return apply_filters('give_forms_columns', $give_form_columns); |
|
55 | 55 | } |
56 | 56 | |
57 | -add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' ); |
|
57 | +add_filter('manage_edit-give_forms_columns', 'give_form_columns'); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Render Give Form Columns |
@@ -66,59 +66,59 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return void |
68 | 68 | */ |
69 | -function give_render_form_columns( $column_name, $post_id ) { |
|
70 | - if ( get_post_type( $post_id ) == 'give_forms' ) { |
|
69 | +function give_render_form_columns($column_name, $post_id) { |
|
70 | + if (get_post_type($post_id) == 'give_forms') { |
|
71 | 71 | |
72 | - switch ( $column_name ) { |
|
72 | + switch ($column_name) { |
|
73 | 73 | case 'form_category': |
74 | - echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' ); |
|
74 | + echo get_the_term_list($post_id, 'give_forms_category', '', ', ', ''); |
|
75 | 75 | break; |
76 | 76 | case 'form_tag': |
77 | - echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' ); |
|
77 | + echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', ''); |
|
78 | 78 | break; |
79 | 79 | case 'price': |
80 | - if ( give_has_variable_prices( $post_id ) ) { |
|
81 | - echo give_price_range( $post_id ); |
|
80 | + if (give_has_variable_prices($post_id)) { |
|
81 | + echo give_price_range($post_id); |
|
82 | 82 | } else { |
83 | - echo give_price( $post_id, false ); |
|
84 | - echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />'; |
|
83 | + echo give_price($post_id, false); |
|
84 | + echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />'; |
|
85 | 85 | } |
86 | 86 | break; |
87 | 87 | case 'goal': |
88 | - if ( give_is_setting_enabled( give_get_meta( $post_id, '_give_goal_option', true ) ) ) { |
|
89 | - echo give_goal( $post_id, false ); |
|
88 | + if (give_is_setting_enabled(give_get_meta($post_id, '_give_goal_option', true))) { |
|
89 | + echo give_goal($post_id, false); |
|
90 | 90 | } else { |
91 | - esc_html_e( 'No Goal Set', 'give' ); |
|
91 | + esc_html_e('No Goal Set', 'give'); |
|
92 | 92 | } |
93 | 93 | |
94 | - echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />'; |
|
94 | + echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />'; |
|
95 | 95 | break; |
96 | 96 | case 'donations': |
97 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
98 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-tools&tab=logs&form=' . $post_id ) ) . '">'; |
|
99 | - echo give_get_form_sales_stats( $post_id ); |
|
97 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
98 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-tools&tab=logs&form='.$post_id)).'">'; |
|
99 | + echo give_get_form_sales_stats($post_id); |
|
100 | 100 | echo '</a>'; |
101 | 101 | } else { |
102 | 102 | echo '-'; |
103 | 103 | } |
104 | 104 | break; |
105 | 105 | case 'earnings': |
106 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
107 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id ) ) . '">'; |
|
108 | - echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ) ) ); |
|
106 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
107 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$post_id)).'">'; |
|
108 | + echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id))); |
|
109 | 109 | echo '</a>'; |
110 | 110 | } else { |
111 | 111 | echo '-'; |
112 | 112 | } |
113 | 113 | break; |
114 | 114 | case 'shortcode': |
115 | - echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="' . absint( $post_id ) . '"]">'; |
|
115 | + echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="'.absint($post_id).'"]">'; |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | -add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 ); |
|
121 | +add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Registers the sortable columns in the list table |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array $columns Array of sortable columns |
131 | 131 | */ |
132 | -function give_sortable_form_columns( $columns ) { |
|
132 | +function give_sortable_form_columns($columns) { |
|
133 | 133 | $columns['price'] = 'amount'; |
134 | 134 | $columns['sales'] = 'sales'; |
135 | 135 | $columns['earnings'] = 'earnings'; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | return $columns; |
140 | 140 | } |
141 | 141 | |
142 | -add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' ); |
|
142 | +add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Sorts Columns in the Forms List Table |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return array $vars Array of all the sort variables |
152 | 152 | */ |
153 | -function give_sort_forms( $vars ) { |
|
153 | +function give_sort_forms($vars) { |
|
154 | 154 | // Check if we're viewing the "give_forms" post type |
155 | - if ( ! isset( $vars['post_type'] ) || ! isset( $vars['orderby'] ) || 'give_forms' !== $vars['post_type'] ) { |
|
155 | + if ( ! isset($vars['post_type']) || ! isset($vars['orderby']) || 'give_forms' !== $vars['post_type']) { |
|
156 | 156 | return $vars; |
157 | 157 | } |
158 | 158 | |
159 | - switch ( $vars['orderby'] ) { |
|
159 | + switch ($vars['orderby']) { |
|
160 | 160 | // Check if 'orderby' is set to "sales" |
161 | 161 | case 'sales': |
162 | 162 | $vars = array_merge( |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return array Array of all sort variables |
227 | 227 | */ |
228 | -function give_filter_forms( $vars ) { |
|
229 | - if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) { |
|
228 | +function give_filter_forms($vars) { |
|
229 | + if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) { |
|
230 | 230 | |
231 | 231 | // If an author ID was passed, use it |
232 | - if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) { |
|
232 | + if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) { |
|
233 | 233 | |
234 | 234 | $author_id = $_REQUEST['author']; |
235 | - if ( (int) $author_id !== get_current_user_id() ) { |
|
235 | + if ((int) $author_id !== get_current_user_id()) { |
|
236 | 236 | // Tried to view the products of another person, sorry |
237 | - wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
237 | + wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
238 | 238 | } |
239 | 239 | $vars = array_merge( |
240 | 240 | $vars, |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | * @return void |
259 | 259 | */ |
260 | 260 | function give_forms_load() { |
261 | - add_filter( 'request', 'give_sort_forms' ); |
|
262 | - add_filter( 'request', 'give_filter_forms' ); |
|
261 | + add_filter('request', 'give_sort_forms'); |
|
262 | + add_filter('request', 'give_filter_forms'); |
|
263 | 263 | } |
264 | 264 | |
265 | -add_action( 'load-edit.php', 'give_forms_load', 9999 ); |
|
265 | +add_action('load-edit.php', 'give_forms_load', 9999); |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Remove Forms Month Filter |
@@ -276,17 +276,17 @@ discard block |
||
276 | 276 | * @global $typenow The post type we are viewing |
277 | 277 | * @return array Empty array disables the dropdown |
278 | 278 | */ |
279 | -function give_remove_month_filter( $dates ) { |
|
279 | +function give_remove_month_filter($dates) { |
|
280 | 280 | global $typenow; |
281 | 281 | |
282 | - if ( $typenow == 'give_forms' ) { |
|
282 | + if ($typenow == 'give_forms') { |
|
283 | 283 | $dates = array(); |
284 | 284 | } |
285 | 285 | |
286 | 286 | return $dates; |
287 | 287 | } |
288 | 288 | |
289 | -add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 ); |
|
289 | +add_filter('months_dropdown_results', 'give_remove_month_filter', 99); |
|
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Updates price when saving post |
@@ -297,23 +297,23 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return int|null |
299 | 299 | */ |
300 | -function give_price_save_quick_edit( $post_id ) { |
|
301 | - if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) { |
|
300 | +function give_price_save_quick_edit($post_id) { |
|
301 | + if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) { |
|
302 | 302 | return; |
303 | 303 | } |
304 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
304 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
305 | 305 | return $post_id; |
306 | 306 | } |
307 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
307 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
308 | 308 | return $post_id; |
309 | 309 | } |
310 | 310 | |
311 | - if ( isset( $_REQUEST['_give_regprice'] ) ) { |
|
312 | - give_update_meta( $post_id, '_give_set_price', strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) ); |
|
311 | + if (isset($_REQUEST['_give_regprice'])) { |
|
312 | + give_update_meta($post_id, '_give_set_price', strip_tags(stripslashes($_REQUEST['_give_regprice']))); |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | -add_action( 'save_post', 'give_price_save_quick_edit' ); |
|
316 | +add_action('save_post', 'give_price_save_quick_edit'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Process bulk edit actions via AJAX |
@@ -323,18 +323,18 @@ discard block |
||
323 | 323 | */ |
324 | 324 | function give_save_bulk_edit() { |
325 | 325 | |
326 | - $post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array(); |
|
326 | + $post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array(); |
|
327 | 327 | |
328 | - if ( ! empty( $post_ids ) && is_array( $post_ids ) ) { |
|
329 | - $price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0; |
|
330 | - foreach ( $post_ids as $post_id ) { |
|
328 | + if ( ! empty($post_ids) && is_array($post_ids)) { |
|
329 | + $price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0; |
|
330 | + foreach ($post_ids as $post_id) { |
|
331 | 331 | |
332 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
332 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
333 | 333 | continue; |
334 | 334 | } |
335 | 335 | |
336 | - if ( ! empty( $price ) ) { |
|
337 | - give_update_meta( $post_id, '_give_set_price', give_sanitize_amount( $price ) ); |
|
336 | + if ( ! empty($price)) { |
|
337 | + give_update_meta($post_id, '_give_set_price', give_sanitize_amount($price)); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | } |
@@ -342,4 +342,4 @@ discard block |
||
342 | 342 | die(); |
343 | 343 | } |
344 | 344 | |
345 | -add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' ); |
|
345 | +add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit'); |
@@ -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 | |
@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_upgrades_screen, $give_donors_page, $give_tools_page; |
34 | 34 | |
35 | 35 | //Payments |
36 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
37 | - $give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' ); |
|
36 | + $give_payment = get_post_type_object('give_payment'); |
|
37 | + $give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page'); |
|
38 | 38 | |
39 | 39 | //Donors |
40 | - $give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donors', 'give' ), esc_html__( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_customers_page' ); |
|
40 | + $give_donors_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donors', 'give'), esc_html__('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_customers_page'); |
|
41 | 41 | |
42 | 42 | //Reports` |
43 | 43 | $give_reports_page = add_submenu_page( |
44 | 44 | 'edit.php?post_type=give_forms', |
45 | - esc_html__( 'Donation Reports', 'give' ), |
|
46 | - esc_html__( 'Reports', 'give' ), |
|
45 | + esc_html__('Donation Reports', 'give'), |
|
46 | + esc_html__('Reports', 'give'), |
|
47 | 47 | 'view_give_reports', |
48 | 48 | 'give-reports', |
49 | 49 | array( |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | //Settings |
56 | 56 | $give_settings_page = add_submenu_page( |
57 | 57 | 'edit.php?post_type=give_forms', |
58 | - esc_html__( 'Give Settings', 'give' ), |
|
59 | - esc_html__( 'Settings', 'give' ), |
|
58 | + esc_html__('Give Settings', 'give'), |
|
59 | + esc_html__('Settings', 'give'), |
|
60 | 60 | 'manage_give_settings', |
61 | 61 | 'give-settings', |
62 | 62 | array( |
@@ -66,21 +66,21 @@ discard block |
||
66 | 66 | ); |
67 | 67 | |
68 | 68 | //Tools. |
69 | - $give_tools_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Tools', 'give' ), esc_html__( 'Tools', 'give' ), 'manage_give_settings', 'give-tools', array( |
|
69 | + $give_tools_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Tools', 'give'), esc_html__('Tools', 'give'), 'manage_give_settings', 'give-tools', array( |
|
70 | 70 | Give()->give_settings, |
71 | 71 | 'output' |
72 | - ) ); |
|
72 | + )); |
|
73 | 73 | |
74 | 74 | //Add-ons |
75 | - $give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Add-ons', 'give' ), esc_html__( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' ); |
|
75 | + $give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Add-ons', 'give'), esc_html__('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page'); |
|
76 | 76 | |
77 | 77 | //Upgrades |
78 | - $give_upgrades_screen = add_submenu_page( null, esc_html__( 'Give Upgrades', 'give' ), esc_html__( 'Give Upgrades', 'give' ), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen' ); |
|
78 | + $give_upgrades_screen = add_submenu_page(null, esc_html__('Give Upgrades', 'give'), esc_html__('Give Upgrades', 'give'), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen'); |
|
79 | 79 | |
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'admin_menu', 'give_add_options_links', 10 ); |
|
83 | +add_action('admin_menu', 'give_add_options_links', 10); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Determines whether the current admin page is a Give admin page. |
@@ -95,224 +95,224 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return bool True if Give admin page. |
97 | 97 | */ |
98 | -function give_is_admin_page( $passed_page = '', $passed_view = '' ) { |
|
98 | +function give_is_admin_page($passed_page = '', $passed_view = '') { |
|
99 | 99 | |
100 | 100 | global $pagenow, $typenow; |
101 | 101 | |
102 | 102 | $found = false; |
103 | - $post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false; |
|
104 | - $action = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false; |
|
105 | - $taxonomy = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false; |
|
106 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
107 | - $view = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false; |
|
108 | - $tab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false; |
|
109 | - |
|
110 | - switch ( $passed_page ) { |
|
103 | + $post_type = isset($_GET['post_type']) ? strtolower($_GET['post_type']) : false; |
|
104 | + $action = isset($_GET['action']) ? strtolower($_GET['action']) : false; |
|
105 | + $taxonomy = isset($_GET['taxonomy']) ? strtolower($_GET['taxonomy']) : false; |
|
106 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
107 | + $view = isset($_GET['view']) ? strtolower($_GET['view']) : false; |
|
108 | + $tab = isset($_GET['tab']) ? strtolower($_GET['tab']) : false; |
|
109 | + |
|
110 | + switch ($passed_page) { |
|
111 | 111 | case 'give_forms': |
112 | - switch ( $passed_view ) { |
|
112 | + switch ($passed_view) { |
|
113 | 113 | case 'list-table': |
114 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) { |
|
114 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php') { |
|
115 | 115 | $found = true; |
116 | 116 | } |
117 | 117 | break; |
118 | 118 | case 'edit': |
119 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) { |
|
119 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post.php') { |
|
120 | 120 | $found = true; |
121 | 121 | } |
122 | 122 | break; |
123 | 123 | case 'new': |
124 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) { |
|
124 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post-new.php') { |
|
125 | 125 | $found = true; |
126 | 126 | } |
127 | 127 | break; |
128 | 128 | default: |
129 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) { |
|
129 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) || 'give_forms' === $post_type || ('post-new.php' == $pagenow && 'give_forms' === $post_type)) { |
|
130 | 130 | $found = true; |
131 | 131 | } |
132 | 132 | break; |
133 | 133 | } |
134 | 134 | break; |
135 | 135 | case 'categories': |
136 | - switch ( $passed_view ) { |
|
136 | + switch ($passed_view) { |
|
137 | 137 | case 'list-table': |
138 | 138 | case 'new': |
139 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) { |
|
139 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy) { |
|
140 | 140 | $found = true; |
141 | 141 | } |
142 | 142 | break; |
143 | 143 | case 'edit': |
144 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) { |
|
144 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy) { |
|
145 | 145 | $found = true; |
146 | 146 | } |
147 | 147 | break; |
148 | 148 | default: |
149 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) { |
|
149 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy) { |
|
150 | 150 | $found = true; |
151 | 151 | } |
152 | 152 | break; |
153 | 153 | } |
154 | 154 | break; |
155 | 155 | case 'tags': |
156 | - switch ( $passed_view ) { |
|
156 | + switch ($passed_view) { |
|
157 | 157 | case 'list-table': |
158 | 158 | case 'new': |
159 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) { |
|
159 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy) { |
|
160 | 160 | $found = true; |
161 | 161 | } |
162 | 162 | break; |
163 | 163 | case 'edit': |
164 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) { |
|
164 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy) { |
|
165 | 165 | $found = true; |
166 | 166 | } |
167 | 167 | break; |
168 | 168 | default: |
169 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) { |
|
169 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy) { |
|
170 | 170 | $found = true; |
171 | 171 | } |
172 | 172 | break; |
173 | 173 | } |
174 | 174 | break; |
175 | 175 | case 'payments': |
176 | - switch ( $passed_view ) { |
|
176 | + switch ($passed_view) { |
|
177 | 177 | case 'list-table': |
178 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) { |
|
178 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view) { |
|
179 | 179 | $found = true; |
180 | 180 | } |
181 | 181 | break; |
182 | 182 | case 'edit': |
183 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view ) { |
|
183 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view) { |
|
184 | 184 | $found = true; |
185 | 185 | } |
186 | 186 | break; |
187 | 187 | default: |
188 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) { |
|
188 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page) { |
|
189 | 189 | $found = true; |
190 | 190 | } |
191 | 191 | break; |
192 | 192 | } |
193 | 193 | break; |
194 | 194 | case 'reports': |
195 | - switch ( $passed_view ) { |
|
195 | + switch ($passed_view) { |
|
196 | 196 | // If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ] |
197 | 197 | case 'earnings': |
198 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { |
|
198 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && ('earnings' === $view || '-1' === $view || false === $view)) { |
|
199 | 199 | $found = true; |
200 | 200 | } |
201 | 201 | break; |
202 | 202 | case 'donors': |
203 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) { |
|
203 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view) { |
|
204 | 204 | $found = true; |
205 | 205 | } |
206 | 206 | break; |
207 | 207 | case 'gateways': |
208 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) { |
|
208 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view) { |
|
209 | 209 | $found = true; |
210 | 210 | } |
211 | 211 | break; |
212 | 212 | case 'export': |
213 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) { |
|
213 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view) { |
|
214 | 214 | $found = true; |
215 | 215 | } |
216 | 216 | break; |
217 | 217 | case 'logs': |
218 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) { |
|
218 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view) { |
|
219 | 219 | $found = true; |
220 | 220 | } |
221 | 221 | break; |
222 | 222 | default: |
223 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
223 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
224 | 224 | $found = true; |
225 | 225 | } |
226 | 226 | break; |
227 | 227 | } |
228 | 228 | break; |
229 | 229 | case 'settings': |
230 | - switch ( $passed_view ) { |
|
230 | + switch ($passed_view) { |
|
231 | 231 | case 'general': |
232 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) { |
|
232 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && ('general' === $tab || false === $tab)) { |
|
233 | 233 | $found = true; |
234 | 234 | } |
235 | 235 | break; |
236 | 236 | case 'gateways': |
237 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) { |
|
237 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab) { |
|
238 | 238 | $found = true; |
239 | 239 | } |
240 | 240 | break; |
241 | 241 | case 'emails': |
242 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) { |
|
242 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab) { |
|
243 | 243 | $found = true; |
244 | 244 | } |
245 | 245 | break; |
246 | 246 | case 'display': |
247 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) { |
|
247 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab) { |
|
248 | 248 | $found = true; |
249 | 249 | } |
250 | 250 | break; |
251 | 251 | case 'licenses': |
252 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) { |
|
252 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab) { |
|
253 | 253 | $found = true; |
254 | 254 | } |
255 | 255 | break; |
256 | 256 | case 'api': |
257 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) { |
|
257 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab) { |
|
258 | 258 | $found = true; |
259 | 259 | } |
260 | 260 | break; |
261 | 261 | case 'advanced': |
262 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) { |
|
262 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab) { |
|
263 | 263 | $found = true; |
264 | 264 | } |
265 | 265 | break; |
266 | 266 | case 'system_info': |
267 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) { |
|
267 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab) { |
|
268 | 268 | $found = true; |
269 | 269 | } |
270 | 270 | break; |
271 | 271 | default: |
272 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) { |
|
272 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page) { |
|
273 | 273 | $found = true; |
274 | 274 | } |
275 | 275 | break; |
276 | 276 | } |
277 | 277 | break; |
278 | 278 | case 'addons': |
279 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) { |
|
279 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-addons' === $page) { |
|
280 | 280 | $found = true; |
281 | 281 | } |
282 | 282 | break; |
283 | 283 | case 'donors': |
284 | - switch ( $passed_view ) { |
|
284 | + switch ($passed_view) { |
|
285 | 285 | case 'list-table': |
286 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) { |
|
286 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view) { |
|
287 | 287 | $found = true; |
288 | 288 | } |
289 | 289 | break; |
290 | 290 | case 'overview': |
291 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) { |
|
291 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view) { |
|
292 | 292 | $found = true; |
293 | 293 | } |
294 | 294 | break; |
295 | 295 | case 'notes': |
296 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) { |
|
296 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view) { |
|
297 | 297 | $found = true; |
298 | 298 | } |
299 | 299 | break; |
300 | 300 | default: |
301 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) { |
|
301 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page) { |
|
302 | 302 | $found = true; |
303 | 303 | } |
304 | 304 | break; |
305 | 305 | } |
306 | 306 | break; |
307 | 307 | case 'reports': |
308 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
308 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
309 | 309 | $found = true; |
310 | 310 | } |
311 | 311 | break; |
312 | 312 | default: |
313 | 313 | global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_upgrades_screen, $give_customers_page, $give_tools_page; |
314 | 314 | |
315 | - $admin_pages = apply_filters( 'give_admin_pages', array( |
|
315 | + $admin_pages = apply_filters('give_admin_pages', array( |
|
316 | 316 | $give_payments_page, |
317 | 317 | $give_settings_page, |
318 | 318 | $give_reports_page, |
@@ -323,19 +323,19 @@ discard block |
||
323 | 323 | $give_customers_page, |
324 | 324 | $give_tools_page, |
325 | 325 | 'widgets.php' |
326 | - ) ); |
|
327 | - if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) { |
|
326 | + )); |
|
327 | + if ('give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow) { |
|
328 | 328 | $found = true; |
329 | - if ( 'give-upgrades' === $page ) { |
|
329 | + if ('give-upgrades' === $page) { |
|
330 | 330 | $found = false; |
331 | 331 | } |
332 | - } elseif ( in_array( $pagenow, $admin_pages ) ) { |
|
332 | + } elseif (in_array($pagenow, $admin_pages)) { |
|
333 | 333 | $found = true; |
334 | 334 | } |
335 | 335 | break; |
336 | 336 | } |
337 | 337 | |
338 | - return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view ); |
|
338 | + return (bool) apply_filters('give_is_admin_page', $found, $page, $view, $passed_page, $passed_view); |
|
339 | 339 | |
340 | 340 | } |
341 | 341 | |
@@ -347,37 +347,37 @@ discard block |
||
347 | 347 | * @param array $settings |
348 | 348 | * @return array |
349 | 349 | */ |
350 | -function give_settings_page_pages( $settings ) { |
|
351 | - include( 'abstract-admin-settings-page.php' ); |
|
352 | - include( 'settings/class-settings-cmb2-backward-compatibility.php' ); |
|
350 | +function give_settings_page_pages($settings) { |
|
351 | + include('abstract-admin-settings-page.php'); |
|
352 | + include('settings/class-settings-cmb2-backward-compatibility.php'); |
|
353 | 353 | |
354 | 354 | $settings = array( |
355 | 355 | // General settings. |
356 | - include( 'settings/class-settings-general.php' ), |
|
356 | + include('settings/class-settings-general.php'), |
|
357 | 357 | |
358 | 358 | // Payment Gateways Settings. |
359 | - include( 'settings/class-settings-gateways.php' ), |
|
359 | + include('settings/class-settings-gateways.php'), |
|
360 | 360 | |
361 | 361 | // Display settings. |
362 | - include( 'settings/class-settings-display.php' ), |
|
362 | + include('settings/class-settings-display.php'), |
|
363 | 363 | |
364 | 364 | // Emails settings. |
365 | - include( 'settings/class-settings-email.php' ), |
|
365 | + include('settings/class-settings-email.php'), |
|
366 | 366 | |
367 | 367 | // Addons settings. |
368 | - include( 'settings/class-settings-addon.php' ), |
|
368 | + include('settings/class-settings-addon.php'), |
|
369 | 369 | |
370 | 370 | // License settings. |
371 | - include( 'settings/class-settings-license.php' ), |
|
371 | + include('settings/class-settings-license.php'), |
|
372 | 372 | |
373 | 373 | // Advanced settinns. |
374 | - include( 'settings/class-settings-advanced.php' ) |
|
374 | + include('settings/class-settings-advanced.php') |
|
375 | 375 | ); |
376 | 376 | |
377 | 377 | // Output. |
378 | 378 | return $settings; |
379 | 379 | } |
380 | -add_filter( 'give-settings_get_settings_pages', 'give_settings_page_pages', 0, 1 ); |
|
380 | +add_filter('give-settings_get_settings_pages', 'give_settings_page_pages', 0, 1); |
|
381 | 381 | |
382 | 382 | |
383 | 383 | /** |
@@ -387,28 +387,28 @@ discard block |
||
387 | 387 | * @param array $settings |
388 | 388 | * @return array |
389 | 389 | */ |
390 | -function give_reports_page_pages( $settings ) { |
|
391 | - include( 'abstract-admin-settings-page.php' ); |
|
390 | +function give_reports_page_pages($settings) { |
|
391 | + include('abstract-admin-settings-page.php'); |
|
392 | 392 | |
393 | 393 | $settings = array( |
394 | 394 | // Earnings. |
395 | - include( 'reporting/class-settings-earnings.php' ), |
|
395 | + include('reporting/class-settings-earnings.php'), |
|
396 | 396 | |
397 | 397 | // Forms. |
398 | - include( 'reporting/class-settings-forms.php' ), |
|
398 | + include('reporting/class-settings-forms.php'), |
|
399 | 399 | |
400 | 400 | // Donors. |
401 | - include( 'reporting/class-settings-donors.php' ), |
|
401 | + include('reporting/class-settings-donors.php'), |
|
402 | 402 | |
403 | 403 | // Gateways. |
404 | - include( 'reporting/class-settings-gateways.php' ), |
|
404 | + include('reporting/class-settings-gateways.php'), |
|
405 | 405 | |
406 | 406 | ); |
407 | 407 | |
408 | 408 | // Output. |
409 | 409 | return $settings; |
410 | 410 | } |
411 | -add_filter( 'give-reports_get_settings_pages', 'give_reports_page_pages', 0, 1 ); |
|
411 | +add_filter('give-reports_get_settings_pages', 'give_reports_page_pages', 0, 1); |
|
412 | 412 | |
413 | 413 | /** |
414 | 414 | * Add setting tab to give-settings page |
@@ -417,31 +417,31 @@ discard block |
||
417 | 417 | * @param array $settings |
418 | 418 | * @return array |
419 | 419 | */ |
420 | -function give_tools_page_pages( $settings ) { |
|
421 | - include( 'abstract-admin-settings-page.php' ); |
|
420 | +function give_tools_page_pages($settings) { |
|
421 | + include('abstract-admin-settings-page.php'); |
|
422 | 422 | |
423 | 423 | $settings = array( |
424 | 424 | // System Info. |
425 | - include( 'tools/class-settings-system-info.php' ), |
|
425 | + include('tools/class-settings-system-info.php'), |
|
426 | 426 | |
427 | 427 | // Logs. |
428 | - include( 'tools/class-settings-logs.php' ), |
|
428 | + include('tools/class-settings-logs.php'), |
|
429 | 429 | |
430 | 430 | // API. |
431 | - include( 'tools/class-settings-api.php' ), |
|
431 | + include('tools/class-settings-api.php'), |
|
432 | 432 | |
433 | 433 | // Data. |
434 | - include( 'tools/class-settings-data.php' ), |
|
434 | + include('tools/class-settings-data.php'), |
|
435 | 435 | |
436 | 436 | // Export. |
437 | - include( 'tools/class-settings-export.php' ), |
|
437 | + include('tools/class-settings-export.php'), |
|
438 | 438 | |
439 | 439 | ); |
440 | 440 | |
441 | 441 | // Output. |
442 | 442 | return $settings; |
443 | 443 | } |
444 | -add_filter( 'give-tools_get_settings_pages', 'give_tools_page_pages', 0, 1 ); |
|
444 | +add_filter('give-tools_get_settings_pages', 'give_tools_page_pages', 0, 1); |
|
445 | 445 | |
446 | 446 | /** |
447 | 447 | * Set default tools page tab. |
@@ -450,10 +450,10 @@ discard block |
||
450 | 450 | * @param string $default_tab Default tab name. |
451 | 451 | * @return string |
452 | 452 | */ |
453 | -function give_set_default_tab_form_tools_page( $default_tab ) { |
|
453 | +function give_set_default_tab_form_tools_page($default_tab) { |
|
454 | 454 | return 'system-info'; |
455 | 455 | } |
456 | -add_filter( 'give_default_setting_tab_give-tools', 'give_set_default_tab_form_tools_page', 10, 1 ); |
|
456 | +add_filter('give_default_setting_tab_give-tools', 'give_set_default_tab_form_tools_page', 10, 1); |
|
457 | 457 | |
458 | 458 | |
459 | 459 | /** |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param string $default_tab Default tab name. |
464 | 464 | * @return string |
465 | 465 | */ |
466 | -function give_set_default_tab_form_reports_page( $default_tab ) { |
|
466 | +function give_set_default_tab_form_reports_page($default_tab) { |
|
467 | 467 | return 'earnings'; |
468 | 468 | } |
469 | -add_filter( 'give_default_setting_tab_give-reports', 'give_set_default_tab_form_reports_page', 10, 1 ); |
|
470 | 469 | \ No newline at end of file |
470 | +add_filter('give_default_setting_tab_give-reports', 'give_set_default_tab_form_reports_page', 10, 1); |
|
471 | 471 | \ No newline at end of file |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | 'disabled' => __( 'Disabled', 'give' ), |
88 | 88 | ) |
89 | 89 | ), |
90 | - array( |
|
91 | - 'name' => __( 'Display Settings Docs Link', 'give' ), |
|
92 | - 'id' => 'display_settings_docs_link', |
|
93 | - 'url' => esc_url( 'http://docs.givewp.com/form-display-options' ), |
|
94 | - 'title' => __( 'Display Options Settings', 'give' ), |
|
95 | - 'type' => 'give_docs_link', |
|
96 | - ), |
|
90 | + array( |
|
91 | + 'name' => __( 'Display Settings Docs Link', 'give' ), |
|
92 | + 'id' => 'display_settings_docs_link', |
|
93 | + 'url' => esc_url( 'http://docs.givewp.com/form-display-options' ), |
|
94 | + 'title' => __( 'Display Options Settings', 'give' ), |
|
95 | + 'type' => 'give_docs_link', |
|
96 | + ), |
|
97 | 97 | array( |
98 | 98 | 'id' => 'give_title_display_settings_1', |
99 | 99 | 'type' => 'sectionend' |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | 'disabled' => __( 'Disabled', 'give' ), |
171 | 171 | ) |
172 | 172 | ), |
173 | - array( |
|
174 | - 'name' => __( 'Post Types Docs Link', 'give' ), |
|
175 | - 'id' => 'post_types_settings_docs_link', |
|
176 | - 'url' => esc_url( 'http://docs.givewp.com/settings-post-types' ), |
|
177 | - 'title' => __( 'Post Types Settings', 'give' ), |
|
178 | - 'type' => 'give_docs_link', |
|
179 | - ), |
|
173 | + array( |
|
174 | + 'name' => __( 'Post Types Docs Link', 'give' ), |
|
175 | + 'id' => 'post_types_settings_docs_link', |
|
176 | + 'url' => esc_url( 'http://docs.givewp.com/settings-post-types' ), |
|
177 | + 'title' => __( 'Post Types Settings', 'give' ), |
|
178 | + 'type' => 'give_docs_link', |
|
179 | + ), |
|
180 | 180 | array( |
181 | 181 | 'id' => 'give_title_display_settings_2', |
182 | 182 | 'type' => 'sectionend' |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | 'disabled' => __( 'Disabled', 'give' ), |
213 | 213 | ) |
214 | 214 | ), |
215 | - array( |
|
216 | - 'name' => __( 'Taxonomies Docs Link', 'give' ), |
|
217 | - 'id' => 'taxonomies_settings_docs_link', |
|
218 | - 'url' => esc_url( 'http://docs.givewp.com/settings-taxonomies' ), |
|
219 | - 'title' => __( 'Taxonomies Settings', 'give' ), |
|
220 | - 'type' => 'give_docs_link', |
|
221 | - ), |
|
215 | + array( |
|
216 | + 'name' => __( 'Taxonomies Docs Link', 'give' ), |
|
217 | + 'id' => 'taxonomies_settings_docs_link', |
|
218 | + 'url' => esc_url( 'http://docs.givewp.com/settings-taxonomies' ), |
|
219 | + 'title' => __( 'Taxonomies Settings', 'give' ), |
|
220 | + 'type' => 'give_docs_link', |
|
221 | + ), |
|
222 | 222 | array( |
223 | 223 | 'id' => 'give_title_display_settings_3', |
224 | 224 | 'type' => 'sectionend' |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | 'id' => 'agreement_text', |
259 | 259 | 'type' => 'wysiwyg' |
260 | 260 | ), |
261 | - array( |
|
262 | - 'name' => __( 'Terms and Conditions Docs Link', 'give' ), |
|
263 | - 'id' => 'terms_settings_docs_link', |
|
264 | - 'url' => esc_url( 'http://docs.givewp.com/settings-terms' ), |
|
265 | - 'title' => __( 'Terms and Conditions Settings', 'give' ), |
|
266 | - 'type' => 'give_docs_link', |
|
267 | - ), |
|
261 | + array( |
|
262 | + 'name' => __( 'Terms and Conditions Docs Link', 'give' ), |
|
263 | + 'id' => 'terms_settings_docs_link', |
|
264 | + 'url' => esc_url( 'http://docs.givewp.com/settings-terms' ), |
|
265 | + 'title' => __( 'Terms and Conditions Settings', 'give' ), |
|
266 | + 'type' => 'give_docs_link', |
|
267 | + ), |
|
268 | 268 | array( |
269 | 269 | 'id' => 'give_title_display_settings_4', |
270 | 270 | 'type' => 'sectionend' |
@@ -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_Display' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Display')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Display. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'display'; |
30 | - $this->label = __( 'Display Options', 'give' ); |
|
30 | + $this->label = __('Display Options', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'display-settings'; |
33 | 33 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $settings = array(); |
45 | 45 | $current_section = give_get_current_setting_section(); |
46 | 46 | |
47 | - switch ( $current_section ) { |
|
47 | + switch ($current_section) { |
|
48 | 48 | case 'display-settings' : |
49 | 49 | $settings = array( |
50 | 50 | // Section 1: Display |
@@ -53,45 +53,45 @@ discard block |
||
53 | 53 | 'type' => 'title' |
54 | 54 | ), |
55 | 55 | array( |
56 | - 'name' => __( 'Default Give Styles', 'give' ), |
|
57 | - 'desc' => __( 'You can disable Give\'s default styles for donation forms and other frontend elements.', 'give' ), |
|
56 | + 'name' => __('Default Give Styles', 'give'), |
|
57 | + 'desc' => __('You can disable Give\'s default styles for donation forms and other frontend elements.', 'give'), |
|
58 | 58 | 'id' => 'css', |
59 | 59 | 'type' => 'radio_inline', |
60 | 60 | 'default' => 'enabled', |
61 | 61 | 'options' => array( |
62 | - 'enabled' => __( 'Enabled', 'give' ), |
|
63 | - 'disabled' => __( 'Disabled', 'give' ), |
|
62 | + 'enabled' => __('Enabled', 'give'), |
|
63 | + 'disabled' => __('Disabled', 'give'), |
|
64 | 64 | ) |
65 | 65 | ), |
66 | 66 | array( |
67 | - 'name' => __( 'Floating Labels', 'give' ), |
|
67 | + 'name' => __('Floating Labels', 'give'), |
|
68 | 68 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
69 | - 'desc' => sprintf( wp_kses( __( '<a href="%s" target="_blank">Floating labels</a> allows your lables to be inset within the form fields to provide a cleaner form appearance. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
69 | + 'desc' => sprintf(wp_kses(__('<a href="%s" target="_blank">Floating labels</a> allows your lables to be inset within the form fields to provide a cleaner form appearance. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give'), array('a' => array('href' => array(), 'target' => array()))), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
70 | 70 | 'id' => 'floatlabels', |
71 | 71 | 'type' => 'radio_inline', |
72 | 72 | 'default' => 'disabled', |
73 | 73 | 'options' => array( |
74 | - 'enabled' => __( 'Enabled', 'give' ), |
|
75 | - 'disabled' => __( 'Disabled', 'give' ), |
|
74 | + 'enabled' => __('Enabled', 'give'), |
|
75 | + 'disabled' => __('Disabled', 'give'), |
|
76 | 76 | ) |
77 | 77 | ), |
78 | 78 | array( |
79 | - 'name' => __( 'Welcome Screen', 'give' ), |
|
79 | + 'name' => __('Welcome Screen', 'give'), |
|
80 | 80 | /* translators: %s: about page URL */ |
81 | - 'desc' => sprintf( wp_kses( __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> that displays each time Give is activated or updated.', 'give' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( admin_url( 'index.php?page=give-about' ) ) ), |
|
81 | + 'desc' => sprintf(wp_kses(__('Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> that displays each time Give is activated or updated.', 'give'), array('a' => array('href' => array(), 'target' => array()))), esc_url(admin_url('index.php?page=give-about'))), |
|
82 | 82 | 'id' => 'welcome', |
83 | 83 | 'type' => 'radio_inline', |
84 | 84 | 'default' => 'enabled', |
85 | 85 | 'options' => array( |
86 | - 'enabled' => __( 'Enabled', 'give' ), |
|
87 | - 'disabled' => __( 'Disabled', 'give' ), |
|
86 | + 'enabled' => __('Enabled', 'give'), |
|
87 | + 'disabled' => __('Disabled', 'give'), |
|
88 | 88 | ) |
89 | 89 | ), |
90 | 90 | array( |
91 | - 'name' => __( 'Display Settings Docs Link', 'give' ), |
|
91 | + 'name' => __('Display Settings Docs Link', 'give'), |
|
92 | 92 | 'id' => 'display_settings_docs_link', |
93 | - 'url' => esc_url( 'http://docs.givewp.com/form-display-options' ), |
|
94 | - 'title' => __( 'Display Options Settings', 'give' ), |
|
93 | + 'url' => esc_url('http://docs.givewp.com/form-display-options'), |
|
94 | + 'title' => __('Display Options Settings', 'give'), |
|
95 | 95 | 'type' => 'give_docs_link', |
96 | 96 | ), |
97 | 97 | array( |
@@ -108,73 +108,73 @@ discard block |
||
108 | 108 | 'type' => 'title' |
109 | 109 | ), |
110 | 110 | array( |
111 | - 'name' => __( 'Form Single Views', 'give' ), |
|
112 | - 'desc' => __( 'By default, all donation form have single views enabled which creates a specific URL on your website for that form. This option disables the singular posts from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ), |
|
111 | + 'name' => __('Form Single Views', 'give'), |
|
112 | + 'desc' => __('By default, all donation form have single views enabled which creates a specific URL on your website for that form. This option disables the singular posts from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'), |
|
113 | 113 | 'id' => 'forms_singular', |
114 | 114 | 'type' => 'radio_inline', |
115 | 115 | 'default' => 'enabled', |
116 | 116 | 'options' => array( |
117 | - 'enabled' => __( 'Enabled', 'give' ), |
|
118 | - 'disabled' => __( 'Disabled', 'give' ), |
|
117 | + 'enabled' => __('Enabled', 'give'), |
|
118 | + 'disabled' => __('Disabled', 'give'), |
|
119 | 119 | ) |
120 | 120 | ), |
121 | 121 | array( |
122 | - 'name' => __( 'Form Archives', 'give' ), |
|
123 | - 'desc' => sprintf( wp_kses( __( 'Archives pages list all the donation forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to <a href="%s">refresh your permalinks</a> after this option has been enabled.', 'give' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( admin_url( 'options-permalink.php' ) ) ), |
|
122 | + 'name' => __('Form Archives', 'give'), |
|
123 | + 'desc' => sprintf(wp_kses(__('Archives pages list all the donation forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to <a href="%s">refresh your permalinks</a> after this option has been enabled.', 'give'), array('a' => array('href' => array(), 'target' => array()))), esc_url(admin_url('options-permalink.php'))), |
|
124 | 124 | 'id' => 'forms_archives', |
125 | 125 | 'type' => 'radio_inline', |
126 | 126 | 'default' => 'enabled', |
127 | 127 | 'options' => array( |
128 | - 'enabled' => __( 'Enabled', 'give' ), |
|
129 | - 'disabled' => __( 'Disabled', 'give' ), |
|
128 | + 'enabled' => __('Enabled', 'give'), |
|
129 | + 'disabled' => __('Disabled', 'give'), |
|
130 | 130 | ) |
131 | 131 | ), |
132 | 132 | array( |
133 | - 'name' => __( 'Form Excerpts', 'give' ), |
|
134 | - 'desc' => __( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ), |
|
133 | + 'name' => __('Form Excerpts', 'give'), |
|
134 | + 'desc' => __('The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give'), |
|
135 | 135 | 'id' => 'forms_excerpt', |
136 | 136 | 'type' => 'radio_inline', |
137 | 137 | 'default' => 'enabled', |
138 | 138 | 'options' => array( |
139 | - 'enabled' => __( 'Enabled', 'give' ), |
|
140 | - 'disabled' => __( 'Disabled', 'give' ), |
|
139 | + 'enabled' => __('Enabled', 'give'), |
|
140 | + 'disabled' => __('Disabled', 'give'), |
|
141 | 141 | ) |
142 | 142 | ), |
143 | 143 | array( |
144 | - 'name' => __( 'Form Featured Image', 'give' ), |
|
145 | - 'desc' => __( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ), |
|
144 | + 'name' => __('Form Featured Image', 'give'), |
|
145 | + 'desc' => __('If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give'), |
|
146 | 146 | 'id' => 'form_featured_img', |
147 | 147 | 'type' => 'radio_inline', |
148 | 148 | 'default' => 'enabled', |
149 | 149 | 'options' => array( |
150 | - 'enabled' => __( 'Enabled', 'give' ), |
|
151 | - 'disabled' => __( 'Disabled', 'give' ), |
|
150 | + 'enabled' => __('Enabled', 'give'), |
|
151 | + 'disabled' => __('Disabled', 'give'), |
|
152 | 152 | ) |
153 | 153 | ), |
154 | 154 | array( |
155 | - 'name' => __( 'Featured Image Size', 'give' ), |
|
156 | - 'desc' => __( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give' ), |
|
155 | + 'name' => __('Featured Image Size', 'give'), |
|
156 | + 'desc' => __('The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give'), |
|
157 | 157 | 'id' => 'featured_image_size', |
158 | 158 | 'type' => 'select', |
159 | 159 | 'default' => 'large', |
160 | 160 | 'options' => give_get_featured_image_sizes() |
161 | 161 | ), |
162 | 162 | array( |
163 | - 'name' => __( 'Single Form Sidebar', 'give' ), |
|
164 | - 'desc' => __( 'The sidebar allows you to add additional widgets to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ), |
|
163 | + 'name' => __('Single Form Sidebar', 'give'), |
|
164 | + 'desc' => __('The sidebar allows you to add additional widgets to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'), |
|
165 | 165 | 'id' => 'form_sidebar', |
166 | 166 | 'type' => 'radio_inline', |
167 | 167 | 'default' => 'enabled', |
168 | 168 | 'options' => array( |
169 | - 'enabled' => __( 'Enabled', 'give' ), |
|
170 | - 'disabled' => __( 'Disabled', 'give' ), |
|
169 | + 'enabled' => __('Enabled', 'give'), |
|
170 | + 'disabled' => __('Disabled', 'give'), |
|
171 | 171 | ) |
172 | 172 | ), |
173 | 173 | array( |
174 | - 'name' => __( 'Post Types Docs Link', 'give' ), |
|
174 | + 'name' => __('Post Types Docs Link', 'give'), |
|
175 | 175 | 'id' => 'post_types_settings_docs_link', |
176 | - 'url' => esc_url( 'http://docs.givewp.com/settings-post-types' ), |
|
177 | - 'title' => __( 'Post Types Settings', 'give' ), |
|
176 | + 'url' => esc_url('http://docs.givewp.com/settings-post-types'), |
|
177 | + 'title' => __('Post Types Settings', 'give'), |
|
178 | 178 | 'type' => 'give_docs_link', |
179 | 179 | ), |
180 | 180 | array( |
@@ -191,32 +191,32 @@ discard block |
||
191 | 191 | 'type' => 'title' |
192 | 192 | ), |
193 | 193 | array( |
194 | - 'name' => __( 'Form Categories', 'give' ), |
|
195 | - 'desc' => __( 'Enable Categories for all Give forms.', 'give' ), |
|
194 | + 'name' => __('Form Categories', 'give'), |
|
195 | + 'desc' => __('Enable Categories for all Give forms.', 'give'), |
|
196 | 196 | 'id' => 'categories', |
197 | 197 | 'type' => 'radio_inline', |
198 | 198 | 'default' => 'disabled', |
199 | 199 | 'options' => array( |
200 | - 'enabled' => __( 'Enabled', 'give' ), |
|
201 | - 'disabled' => __( 'Disabled', 'give' ), |
|
200 | + 'enabled' => __('Enabled', 'give'), |
|
201 | + 'disabled' => __('Disabled', 'give'), |
|
202 | 202 | ) |
203 | 203 | ), |
204 | 204 | array( |
205 | - 'name' => __( 'Form Tags', 'give' ), |
|
206 | - 'desc' => __( 'Enable Tags for all Give forms.', 'give' ), |
|
205 | + 'name' => __('Form Tags', 'give'), |
|
206 | + 'desc' => __('Enable Tags for all Give forms.', 'give'), |
|
207 | 207 | 'id' => 'tags', |
208 | 208 | 'type' => 'radio_inline', |
209 | 209 | 'default' => 'disabled', |
210 | 210 | 'options' => array( |
211 | - 'enabled' => __( 'Enabled', 'give' ), |
|
212 | - 'disabled' => __( 'Disabled', 'give' ), |
|
211 | + 'enabled' => __('Enabled', 'give'), |
|
212 | + 'disabled' => __('Disabled', 'give'), |
|
213 | 213 | ) |
214 | 214 | ), |
215 | 215 | array( |
216 | - 'name' => __( 'Taxonomies Docs Link', 'give' ), |
|
216 | + 'name' => __('Taxonomies Docs Link', 'give'), |
|
217 | 217 | 'id' => 'taxonomies_settings_docs_link', |
218 | - 'url' => esc_url( 'http://docs.givewp.com/settings-taxonomies' ), |
|
219 | - 'title' => __( 'Taxonomies Settings', 'give' ), |
|
218 | + 'url' => esc_url('http://docs.givewp.com/settings-taxonomies'), |
|
219 | + 'title' => __('Taxonomies Settings', 'give'), |
|
220 | 220 | 'type' => 'give_docs_link', |
221 | 221 | ), |
222 | 222 | array( |
@@ -233,36 +233,36 @@ discard block |
||
233 | 233 | 'type' => 'title' |
234 | 234 | ), |
235 | 235 | array( |
236 | - 'name' => __( 'Terms and Conditions', 'give' ), |
|
237 | - 'desc' => __( 'Would you like donors to require that donors agree to your terms when donating? Note: You can enable/disable this option and customize the terms per form as well.', 'give' ), |
|
236 | + 'name' => __('Terms and Conditions', 'give'), |
|
237 | + 'desc' => __('Would you like donors to require that donors agree to your terms when donating? Note: You can enable/disable this option and customize the terms per form as well.', 'give'), |
|
238 | 238 | 'id' => 'terms', |
239 | 239 | 'type' => 'radio_inline', |
240 | 240 | 'default' => 'disabled', |
241 | 241 | 'options' => array( |
242 | - 'enabled' => __( 'Enabled', 'give' ), |
|
243 | - 'disabled' => __( 'Disabled', 'give' ), |
|
242 | + 'enabled' => __('Enabled', 'give'), |
|
243 | + 'disabled' => __('Disabled', 'give'), |
|
244 | 244 | ) |
245 | 245 | ), |
246 | 246 | array( |
247 | - 'name' => __( 'Agree to Terms Label', 'give' ), |
|
248 | - 'desc' => __( 'The label shown next to the agree to terms check box. Customize it here or leave blank to use the default placeholder text. Note: You can customize the label per form.', 'give' ), |
|
247 | + 'name' => __('Agree to Terms Label', 'give'), |
|
248 | + 'desc' => __('The label shown next to the agree to terms check box. Customize it here or leave blank to use the default placeholder text. Note: You can customize the label per form.', 'give'), |
|
249 | 249 | 'id' => 'agree_to_terms_label', |
250 | 250 | 'attributes' => array( |
251 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
251 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
252 | 252 | ), |
253 | 253 | 'type' => 'text' |
254 | 254 | ), |
255 | 255 | array( |
256 | - 'name' => __( 'Agreement Text', 'give' ), |
|
257 | - 'desc' => __( 'This is the actual text which the user will be asked to agree to in order to donate. Note: You can customize the content per form as needed.', 'give' ), |
|
256 | + 'name' => __('Agreement Text', 'give'), |
|
257 | + 'desc' => __('This is the actual text which the user will be asked to agree to in order to donate. Note: You can customize the content per form as needed.', 'give'), |
|
258 | 258 | 'id' => 'agreement_text', |
259 | 259 | 'type' => 'wysiwyg' |
260 | 260 | ), |
261 | 261 | array( |
262 | - 'name' => __( 'Terms and Conditions Docs Link', 'give' ), |
|
262 | + 'name' => __('Terms and Conditions Docs Link', 'give'), |
|
263 | 263 | 'id' => 'terms_settings_docs_link', |
264 | - 'url' => esc_url( 'http://docs.givewp.com/settings-terms' ), |
|
265 | - 'title' => __( 'Terms and Conditions Settings', 'give' ), |
|
264 | + 'url' => esc_url('http://docs.givewp.com/settings-terms'), |
|
265 | + 'title' => __('Terms and Conditions Settings', 'give'), |
|
266 | 266 | 'type' => 'give_docs_link', |
267 | 267 | ), |
268 | 268 | array( |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * Filter the display options settings. |
278 | 278 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
279 | 279 | */ |
280 | - $settings = apply_filters( 'give_settings_display', $settings ); |
|
280 | + $settings = apply_filters('give_settings_display', $settings); |
|
281 | 281 | |
282 | 282 | /** |
283 | 283 | * Filter the settings. |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @since 1.8 |
286 | 286 | * @param array $settings |
287 | 287 | */ |
288 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
288 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
289 | 289 | |
290 | 290 | // Output. |
291 | 291 | return $settings; |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | */ |
300 | 300 | public function get_sections() { |
301 | 301 | $sections = array( |
302 | - 'display-settings' => __( 'Display', 'give' ), |
|
303 | - 'post-types' => __( 'Post Types', 'give' ), |
|
304 | - 'taxonomies' => __( 'Taxonomies', 'give' ), |
|
305 | - 'term-and-conditions' => __( 'Terms and Conditions', 'give' ) |
|
302 | + 'display-settings' => __('Display', 'give'), |
|
303 | + 'post-types' => __('Post Types', 'give'), |
|
304 | + 'taxonomies' => __('Taxonomies', 'give'), |
|
305 | + 'term-and-conditions' => __('Terms and Conditions', 'give') |
|
306 | 306 | ); |
307 | 307 | |
308 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
308 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 |
@@ -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 | |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | * @param $_step int The step to process |
107 | 107 | * @since 1.5 |
108 | 108 | */ |
109 | - public function __construct( $_step = 1 ) { |
|
109 | + public function __construct($_step = 1) { |
|
110 | 110 | |
111 | 111 | $upload_dir = wp_upload_dir(); |
112 | 112 | $this->filetype = '.csv'; |
113 | - $this->filename = 'give-' . $this->export_type . $this->filetype; |
|
114 | - $this->file = trailingslashit( $upload_dir['basedir'] ) . $this->filename; |
|
113 | + $this->filename = 'give-'.$this->export_type.$this->filetype; |
|
114 | + $this->file = trailingslashit($upload_dir['basedir']).$this->filename; |
|
115 | 115 | |
116 | - if ( ! is_writeable( $upload_dir['basedir'] ) ) { |
|
116 | + if ( ! is_writeable($upload_dir['basedir'])) { |
|
117 | 117 | $this->is_writable = false; |
118 | 118 | } |
119 | 119 | |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function process_step() { |
131 | 131 | |
132 | - if ( ! $this->can_export() ) { |
|
133 | - wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
132 | + if ( ! $this->can_export()) { |
|
133 | + wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
134 | 134 | } |
135 | 135 | |
136 | - if( $this->step < 2 ) { |
|
136 | + if ($this->step < 2) { |
|
137 | 137 | |
138 | 138 | // Make sure we start with a fresh file on step 1 |
139 | - @unlink( $this->file ); |
|
139 | + @unlink($this->file); |
|
140 | 140 | $this->print_csv_cols(); |
141 | 141 | } |
142 | 142 | |
143 | 143 | $rows = $this->print_csv_rows(); |
144 | 144 | |
145 | - if( $rows ) { |
|
145 | + if ($rows) { |
|
146 | 146 | return true; |
147 | 147 | } else { |
148 | 148 | return false; |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | $col_data = ''; |
163 | 163 | $cols = $this->get_csv_cols(); |
164 | 164 | $i = 1; |
165 | - foreach( $cols as $col_id => $column ) { |
|
166 | - $col_data .= '"' . addslashes( $column ) . '"'; |
|
167 | - $col_data .= $i == count( $cols ) ? '' : ','; |
|
165 | + foreach ($cols as $col_id => $column) { |
|
166 | + $col_data .= '"'.addslashes($column).'"'; |
|
167 | + $col_data .= $i == count($cols) ? '' : ','; |
|
168 | 168 | $i++; |
169 | 169 | } |
170 | 170 | $col_data .= "\r\n"; |
171 | 171 | |
172 | - $this->stash_step_data( $col_data ); |
|
172 | + $this->stash_step_data($col_data); |
|
173 | 173 | |
174 | 174 | return $col_data; |
175 | 175 | |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | $data = $this->get_data(); |
189 | 189 | $cols = $this->get_csv_cols(); |
190 | 190 | |
191 | - if( $data ) { |
|
191 | + if ($data) { |
|
192 | 192 | |
193 | 193 | // Output each row |
194 | - foreach ( $data as $row ) { |
|
194 | + foreach ($data as $row) { |
|
195 | 195 | $i = 1; |
196 | - foreach ( $row as $col_id => $column ) { |
|
196 | + foreach ($row as $col_id => $column) { |
|
197 | 197 | // Make sure the column is valid |
198 | - if ( array_key_exists( $col_id, $cols ) ) { |
|
199 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
200 | - $row_data .= $i == count( $cols ) ? '' : ','; |
|
198 | + if (array_key_exists($col_id, $cols)) { |
|
199 | + $row_data .= '"'.addslashes(preg_replace("/\"/", "'", $column)).'"'; |
|
200 | + $row_data .= $i == count($cols) ? '' : ','; |
|
201 | 201 | $i++; |
202 | 202 | } |
203 | 203 | } |
204 | 204 | $row_data .= "\r\n"; |
205 | 205 | } |
206 | 206 | |
207 | - $this->stash_step_data( $row_data ); |
|
207 | + $this->stash_step_data($row_data); |
|
208 | 208 | |
209 | 209 | return $row_data; |
210 | 210 | } |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | |
233 | 233 | $file = ''; |
234 | 234 | |
235 | - if ( @file_exists( $this->file ) ) { |
|
235 | + if (@file_exists($this->file)) { |
|
236 | 236 | |
237 | - if ( ! is_writeable( $this->file ) ) { |
|
237 | + if ( ! is_writeable($this->file)) { |
|
238 | 238 | $this->is_writable = false; |
239 | 239 | } |
240 | 240 | |
241 | - $file = @file_get_contents( $this->file ); |
|
241 | + $file = @file_get_contents($this->file); |
|
242 | 242 | |
243 | 243 | } else { |
244 | 244 | |
245 | - @file_put_contents( $this->file, '' ); |
|
246 | - @chmod( $this->file, 0664 ); |
|
245 | + @file_put_contents($this->file, ''); |
|
246 | + @chmod($this->file, 0664); |
|
247 | 247 | |
248 | 248 | } |
249 | 249 | |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | * @param $data string The data to add to the file |
258 | 258 | * @return void |
259 | 259 | */ |
260 | - protected function stash_step_data( $data = '' ) { |
|
260 | + protected function stash_step_data($data = '') { |
|
261 | 261 | |
262 | 262 | $file = $this->get_file(); |
263 | 263 | $file .= $data; |
264 | - @file_put_contents( $this->file, $file ); |
|
264 | + @file_put_contents($this->file, $file); |
|
265 | 265 | |
266 | 266 | // If we have no rows after this step, mark it as an empty export |
267 | - $file_rows = file( $this->file, FILE_SKIP_EMPTY_LINES); |
|
267 | + $file_rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
268 | 268 | $default_cols = $this->get_csv_cols(); |
269 | - $default_cols = empty( $default_cols ) ? 0 : 1; |
|
269 | + $default_cols = empty($default_cols) ? 0 : 1; |
|
270 | 270 | |
271 | - $this->is_empty = count( $file_rows ) == $default_cols ? true : false; |
|
271 | + $this->is_empty = count($file_rows) == $default_cols ? true : false; |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | |
287 | 287 | $file = $this->get_file(); |
288 | 288 | |
289 | - @unlink( $this->file ); |
|
289 | + @unlink($this->file); |
|
290 | 290 | |
291 | 291 | echo $file; |
292 | 292 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @since 1.8 |
297 | 297 | */ |
298 | - do_action( 'give_file_export_complete', $_REQUEST ); |
|
298 | + do_action('give_file_export_complete', $_REQUEST); |
|
299 | 299 | |
300 | 300 | give_die(); |
301 | 301 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @since 1.5 |
307 | 307 | * @param array $request The Form Data passed into the batch processing |
308 | 308 | */ |
309 | - public function set_properties( $request ) {} |
|
309 | + public function set_properties($request) {} |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Allow for prefetching of data for the remainder of the exporter |
@@ -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 | |
@@ -62,26 +62,26 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param array $request The Form Data passed into the batch processing |
64 | 64 | */ |
65 | - public function set_properties( $request ) { |
|
65 | + public function set_properties($request) { |
|
66 | 66 | |
67 | 67 | // Set data from form submission |
68 | - if ( isset( $_POST['form'] ) ) { |
|
69 | - parse_str( $_POST['form'], $this->data ); |
|
68 | + if (isset($_POST['form'])) { |
|
69 | + parse_str($_POST['form'], $this->data); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $this->form = $this->data['forms']; |
73 | 73 | |
74 | 74 | // Setup donor ids cache. |
75 | - if( ! empty( $this->form ) ) { |
|
75 | + if ( ! empty($this->form)) { |
|
76 | 76 | // Cache donor ids to output unique list of donor. |
77 | - $this->query_id = give_clean( $_REQUEST['give_export_option']['query_id'] ); |
|
78 | - if( ! ( $this->donor_ids = Give_Cache::get( $this->query_id, true ) ) ) { |
|
77 | + $this->query_id = give_clean($_REQUEST['give_export_option']['query_id']); |
|
78 | + if ( ! ($this->donor_ids = Give_Cache::get($this->query_id, true))) { |
|
79 | 79 | $this->donor_ids = array(); |
80 | - Give_Cache::set( $this->query_id, $this->donor_ids, HOUR_IN_SECONDS, true ); |
|
80 | + Give_Cache::set($this->query_id, $this->donor_ids, HOUR_IN_SECONDS, true); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | - $this->price_id = ! empty( $request['give_price_option'] ) && 'all' !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
84 | + $this->price_id = ! empty($request['give_price_option']) && 'all' !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function csv_cols() { |
96 | 96 | |
97 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
97 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
98 | 98 | |
99 | 99 | // We need columns. |
100 | - if ( empty( $columns ) ) { |
|
100 | + if (empty($columns)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | - $cols = $this->get_cols( $columns ); |
|
104 | + $cols = $this->get_cols($columns); |
|
105 | 105 | |
106 | 106 | return $cols; |
107 | 107 | } |
@@ -113,38 +113,38 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - private function get_cols( $columns ) { |
|
116 | + private function get_cols($columns) { |
|
117 | 117 | |
118 | 118 | $cols = array(); |
119 | 119 | |
120 | - foreach ( $columns as $key => $value ) { |
|
120 | + foreach ($columns as $key => $value) { |
|
121 | 121 | |
122 | - switch ( $key ) { |
|
122 | + switch ($key) { |
|
123 | 123 | case 'full_name' : |
124 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
124 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
125 | 125 | break; |
126 | 126 | case 'email' : |
127 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
127 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
128 | 128 | break; |
129 | 129 | case 'address' : |
130 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
131 | - $cols['address_line2'] = esc_html__( 'Address 2', 'give' ); |
|
132 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
133 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
134 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
135 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
130 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
131 | + $cols['address_line2'] = esc_html__('Address 2', 'give'); |
|
132 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
133 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
134 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
135 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
136 | 136 | break; |
137 | 137 | case 'userid' : |
138 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
138 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
139 | 139 | break; |
140 | 140 | case 'date_first_donated' : |
141 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
141 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
142 | 142 | break; |
143 | 143 | case 'donations' : |
144 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
144 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
145 | 145 | break; |
146 | 146 | case 'donation_sum' : |
147 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
147 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
148 | 148 | break; |
149 | 149 | } |
150 | 150 | } |
@@ -167,20 +167,20 @@ discard block |
||
167 | 167 | |
168 | 168 | $i = 0; |
169 | 169 | |
170 | - if ( ! empty( $this->form ) ) { |
|
170 | + if ( ! empty($this->form)) { |
|
171 | 171 | |
172 | 172 | // Export donors of a specific product |
173 | 173 | global $give_logs; |
174 | 174 | |
175 | 175 | $args = array( |
176 | - 'post_parent' => absint( $this->form ), |
|
176 | + 'post_parent' => absint($this->form), |
|
177 | 177 | 'log_type' => 'sale', |
178 | 178 | 'posts_per_page' => 30, |
179 | 179 | 'paged' => $this->step, |
180 | 180 | ); |
181 | 181 | |
182 | 182 | // Check for price option |
183 | - if ( null !== $this->price_id ) { |
|
183 | + if (null !== $this->price_id) { |
|
184 | 184 | $args['meta_query'] = array( |
185 | 185 | array( |
186 | 186 | 'key' => '_give_log_price_id', |
@@ -189,44 +189,44 @@ discard block |
||
189 | 189 | ); |
190 | 190 | } |
191 | 191 | |
192 | - $logs = $give_logs->get_connected_logs( $args ); |
|
192 | + $logs = $give_logs->get_connected_logs($args); |
|
193 | 193 | |
194 | - if ( $logs ) { |
|
195 | - foreach ( $logs as $log ) { |
|
196 | - $payment_id = give_get_meta( $log->ID, '_give_log_payment_id', true ); |
|
197 | - $payment = new Give_Payment( $payment_id ); |
|
194 | + if ($logs) { |
|
195 | + foreach ($logs as $log) { |
|
196 | + $payment_id = give_get_meta($log->ID, '_give_log_payment_id', true); |
|
197 | + $payment = new Give_Payment($payment_id); |
|
198 | 198 | |
199 | 199 | // Continue if donor already included. |
200 | - if( in_array( $payment->customer_id , $this->donor_ids ) ) { |
|
200 | + if (in_array($payment->customer_id, $this->donor_ids)) { |
|
201 | 201 | continue; |
202 | 202 | } |
203 | 203 | |
204 | 204 | $this->donor_ids[] = $payment->customer_id; |
205 | 205 | |
206 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
207 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
208 | - $i ++; |
|
206 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
207 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
208 | + $i++; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | // Cache donor ids only if admin export donor for specific form. |
212 | - Give_Cache::set( $this->query_id, array_unique( $this->donor_ids ), HOUR_IN_SECONDS, true ); |
|
212 | + Give_Cache::set($this->query_id, array_unique($this->donor_ids), HOUR_IN_SECONDS, true); |
|
213 | 213 | } |
214 | 214 | } else { |
215 | 215 | |
216 | 216 | // Export all donors. |
217 | - $offset = 30 * ( $this->step - 1 ); |
|
218 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
217 | + $offset = 30 * ($this->step - 1); |
|
218 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
219 | 219 | |
220 | - foreach ( $donors as $donor ) { |
|
220 | + foreach ($donors as $donor) { |
|
221 | 221 | |
222 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
223 | - $i ++; |
|
222 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
223 | + $i++; |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | 227 | |
228 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
229 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
228 | + $data = apply_filters('give_export_get_data', $data); |
|
229 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
230 | 230 | |
231 | 231 | return $data; |
232 | 232 | } |
@@ -242,18 +242,18 @@ discard block |
||
242 | 242 | $percentage = 0; |
243 | 243 | |
244 | 244 | // We can't count the number when getting them for a specific form |
245 | - if ( empty( $this->form ) ) { |
|
245 | + if (empty($this->form)) { |
|
246 | 246 | |
247 | 247 | $total = Give()->customers->count(); |
248 | 248 | |
249 | - if ( $total > 0 ) { |
|
249 | + if ($total > 0) { |
|
250 | 250 | |
251 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
251 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
252 | 252 | |
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
256 | - if ( $percentage > 100 ) { |
|
256 | + if ($percentage > 100) { |
|
257 | 257 | $percentage = 100; |
258 | 258 | } |
259 | 259 | |
@@ -269,46 +269,46 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return mixed |
271 | 271 | */ |
272 | - private function set_donor_data( $i, $data, $donor ) { |
|
272 | + private function set_donor_data($i, $data, $donor) { |
|
273 | 273 | |
274 | 274 | $columns = $this->csv_cols(); |
275 | 275 | |
276 | 276 | // Set address variable |
277 | 277 | $address = ''; |
278 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
279 | - $address = give_get_donor_address( $donor->user_id ); |
|
278 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
279 | + $address = give_get_donor_address($donor->user_id); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | // Set columns |
283 | - if ( ! empty( $columns['full_name'] ) ) { |
|
284 | - $data[ $i ]['full_name'] = $donor->name; |
|
283 | + if ( ! empty($columns['full_name'])) { |
|
284 | + $data[$i]['full_name'] = $donor->name; |
|
285 | 285 | } |
286 | - if ( ! empty( $columns['email'] ) ) { |
|
287 | - $data[ $i ]['email'] = $donor->email; |
|
286 | + if ( ! empty($columns['email'])) { |
|
287 | + $data[$i]['email'] = $donor->email; |
|
288 | 288 | } |
289 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
290 | - |
|
291 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
292 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
293 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
294 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
295 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
296 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
289 | + if ( ! empty($columns['address_line1'])) { |
|
290 | + |
|
291 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
292 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
293 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
294 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
295 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
296 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
297 | 297 | } |
298 | - if ( ! empty( $columns['userid'] ) ) { |
|
299 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
298 | + if ( ! empty($columns['userid'])) { |
|
299 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
300 | 300 | } |
301 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
302 | - $data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) ); |
|
301 | + if ( ! empty($columns['date_first_donated'])) { |
|
302 | + $data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created)); |
|
303 | 303 | } |
304 | - if ( ! empty( $columns['donations'] ) ) { |
|
305 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
304 | + if ( ! empty($columns['donations'])) { |
|
305 | + $data[$i]['donations'] = $donor->purchase_count; |
|
306 | 306 | } |
307 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
308 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
307 | + if ( ! empty($columns['donation_sum'])) { |
|
308 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
309 | 309 | } |
310 | 310 | |
311 | - return $data[ $i ]; |
|
311 | + return $data[$i]; |
|
312 | 312 | |
313 | 313 | } |
314 | 314 |