@@ -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' => __( 'Name', 'give' ), |
|
36 | - 'form_category' => __( 'Categories', 'give' ), |
|
37 | - 'form_tag' => __( 'Tags', 'give' ), |
|
38 | - 'price' => __( 'Amount', 'give' ), |
|
39 | - 'goal' => __( 'Goal', 'give' ), |
|
40 | - 'donations' => __( 'Donations', 'give' ), |
|
41 | - 'earnings' => __( 'Income', 'give' ), |
|
42 | - 'shortcode' => __( 'Shortcode', 'give' ), |
|
43 | - 'date' => __( 'Date', 'give' ), |
|
35 | + 'title' => __('Name', 'give'), |
|
36 | + 'form_category' => __('Categories', 'give'), |
|
37 | + 'form_tag' => __('Tags', 'give'), |
|
38 | + 'price' => __('Amount', 'give'), |
|
39 | + 'goal' => __('Goal', 'give'), |
|
40 | + 'donations' => __('Donations', 'give'), |
|
41 | + 'earnings' => __('Income', 'give'), |
|
42 | + 'shortcode' => __('Shortcode', 'give'), |
|
43 | + 'date' => __('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,70 +66,70 @@ 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 | - printf( '<input type="hidden" class="formprice-%1$s" value="%2$s" />', esc_attr( $post_id ), esc_attr( give_get_form_price( $post_id ) ) ); |
|
83 | + echo give_price($post_id, false); |
|
84 | + printf('<input type="hidden" class="formprice-%1$s" value="%2$s" />', esc_attr($post_id), esc_attr(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 ) ) ) { |
|
88 | + if (give_is_setting_enabled(give_get_meta($post_id, '_give_goal_option', true))) { |
|
89 | 89 | |
90 | - echo give_admin_form_goal_stats( $post_id ); |
|
90 | + echo give_admin_form_goal_stats($post_id); |
|
91 | 91 | |
92 | 92 | } else { |
93 | - _e( 'No Goal Set', 'give' ); |
|
93 | + _e('No Goal Set', 'give'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | printf( |
97 | 97 | '<input type="hidden" class="formgoal-%1$s" value="%2$s" />', |
98 | - esc_attr( $post_id ), |
|
99 | - give_get_form_goal( $post_id ) |
|
98 | + esc_attr($post_id), |
|
99 | + give_get_form_goal($post_id) |
|
100 | 100 | ); |
101 | 101 | |
102 | 102 | break; |
103 | 103 | case 'donations': |
104 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
104 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
105 | 105 | printf( |
106 | 106 | '<a href="%1$s">%2$s</a>', |
107 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . $post_id ) ), |
|
108 | - give_get_form_sales_stats( $post_id ) |
|
107 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-payment-history&form_id='.$post_id)), |
|
108 | + give_get_form_sales_stats($post_id) |
|
109 | 109 | ); |
110 | 110 | } else { |
111 | 111 | echo '-'; |
112 | 112 | } |
113 | 113 | break; |
114 | 114 | case 'earnings': |
115 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
115 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
116 | 116 | printf( |
117 | 117 | '<a href="%1$s">%2$s</a>', |
118 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $post_id ) ), |
|
119 | - give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ), array( 'sanitize' => false ) ) ) |
|
118 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id='.$post_id)), |
|
119 | + give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id), array('sanitize' => false))) |
|
120 | 120 | ); |
121 | 121 | } else { |
122 | 122 | echo '-'; |
123 | 123 | } |
124 | 124 | break; |
125 | 125 | case 'shortcode': |
126 | - printf( '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="%s"]"', absint( $post_id ) ); |
|
126 | + printf('<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="%s"]"', absint($post_id)); |
|
127 | 127 | break; |
128 | 128 | }// End switch(). |
129 | 129 | }// End if(). |
130 | 130 | } |
131 | 131 | |
132 | -add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 ); |
|
132 | +add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2); |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Registers the sortable columns in the list table |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return array $columns Array of sortable columns |
142 | 142 | */ |
143 | -function give_sortable_form_columns( $columns ) { |
|
143 | +function give_sortable_form_columns($columns) { |
|
144 | 144 | $columns['price'] = 'amount'; |
145 | 145 | $columns['sales'] = 'sales'; |
146 | 146 | $columns['earnings'] = 'earnings'; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | return $columns; |
151 | 151 | } |
152 | 152 | |
153 | -add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' ); |
|
153 | +add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns'); |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Sorts Columns in the Forms List Table |
@@ -161,13 +161,13 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return array $vars Array of all the sort variables. |
163 | 163 | */ |
164 | -function give_sort_forms( $vars ) { |
|
164 | +function give_sort_forms($vars) { |
|
165 | 165 | // Check if we're viewing the "give_forms" post type. |
166 | - if ( ! isset( $vars['post_type'] ) || ! isset( $vars['orderby'] ) || 'give_forms' !== $vars['post_type'] ) { |
|
166 | + if ( ! isset($vars['post_type']) || ! isset($vars['orderby']) || 'give_forms' !== $vars['post_type']) { |
|
167 | 167 | return $vars; |
168 | 168 | } |
169 | 169 | |
170 | - switch ( $vars['orderby'] ) { |
|
170 | + switch ($vars['orderby']) { |
|
171 | 171 | // Check if 'orderby' is set to "sales". |
172 | 172 | case 'sales': |
173 | 173 | $vars = array_merge( |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | // Check if "orderby" is set to "price/amount". |
194 | 194 | case 'amount': |
195 | - $multi_level_meta_key = ( 'asc' === $vars['order'] ) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount'; |
|
195 | + $multi_level_meta_key = ('asc' === $vars['order']) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount'; |
|
196 | 196 | |
197 | 197 | $vars['orderby'] = 'meta_value_num'; |
198 | 198 | $vars['meta_query'] = array( |
@@ -244,17 +244,17 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return array Array of all sort variables. |
246 | 246 | */ |
247 | -function give_filter_forms( $vars ) { |
|
248 | - if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) { |
|
247 | +function give_filter_forms($vars) { |
|
248 | + if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) { |
|
249 | 249 | |
250 | 250 | // If an author ID was passed, use it |
251 | - if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) { |
|
251 | + if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) { |
|
252 | 252 | |
253 | 253 | $author_id = $_REQUEST['author']; |
254 | - if ( (int) $author_id !== get_current_user_id() ) { |
|
255 | - wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
254 | + if ((int) $author_id !== get_current_user_id()) { |
|
255 | + wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array( |
|
256 | 256 | 'response' => 403, |
257 | - ) ); |
|
257 | + )); |
|
258 | 258 | } |
259 | 259 | $vars = array_merge( |
260 | 260 | $vars, |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | * @return void |
279 | 279 | */ |
280 | 280 | function give_forms_load() { |
281 | - add_filter( 'request', 'give_sort_forms' ); |
|
282 | - add_filter( 'request', 'give_filter_forms' ); |
|
281 | + add_filter('request', 'give_sort_forms'); |
|
282 | + add_filter('request', 'give_filter_forms'); |
|
283 | 283 | } |
284 | 284 | |
285 | -add_action( 'load-edit.php', 'give_forms_load', 9999 ); |
|
285 | +add_action('load-edit.php', 'give_forms_load', 9999); |
|
286 | 286 | |
287 | 287 | /** |
288 | 288 | * Remove Forms Month Filter |
@@ -296,17 +296,17 @@ discard block |
||
296 | 296 | * @global $typenow The post type we are viewing. |
297 | 297 | * @return array Empty array disables the dropdown. |
298 | 298 | */ |
299 | -function give_remove_month_filter( $dates ) { |
|
299 | +function give_remove_month_filter($dates) { |
|
300 | 300 | global $typenow; |
301 | 301 | |
302 | - if ( $typenow == 'give_forms' ) { |
|
302 | + if ($typenow == 'give_forms') { |
|
303 | 303 | $dates = array(); |
304 | 304 | } |
305 | 305 | |
306 | 306 | return $dates; |
307 | 307 | } |
308 | 308 | |
309 | -add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 ); |
|
309 | +add_filter('months_dropdown_results', 'give_remove_month_filter', 99); |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Updates price when saving post |
@@ -318,33 +318,33 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return int|null |
320 | 320 | */ |
321 | -function give_price_save_quick_edit( $post_id ) { |
|
322 | - if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) { |
|
321 | +function give_price_save_quick_edit($post_id) { |
|
322 | + if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) { |
|
323 | 323 | return; |
324 | 324 | } |
325 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
325 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
326 | 326 | return $post_id; |
327 | 327 | } |
328 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
328 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
329 | 329 | return $post_id; |
330 | 330 | } |
331 | 331 | |
332 | - if ( isset( $_REQUEST['_give_regprice'] ) ) { |
|
333 | - give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) ) ); |
|
332 | + if (isset($_REQUEST['_give_regprice'])) { |
|
333 | + give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db(strip_tags(stripslashes($_REQUEST['_give_regprice'])))); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // Override the Donation minimum amount. |
337 | 337 | if ( |
338 | - isset( $_REQUEST['_give_custom_amount'], $_REQUEST['_give_set_price'], $_REQUEST['_give_price_option'], $_REQUEST['_give_custom_amount_range'] ) |
|
338 | + isset($_REQUEST['_give_custom_amount'], $_REQUEST['_give_set_price'], $_REQUEST['_give_price_option'], $_REQUEST['_give_custom_amount_range']) |
|
339 | 339 | && 'set' === $_REQUEST['_give_price_option'] |
340 | - && give_is_setting_enabled( $_REQUEST['_give_custom_amount'] ) |
|
341 | - && give_maybe_sanitize_amount( $_REQUEST['_give_set_price'] ) < give_maybe_sanitize_amount( $_REQUEST['_give_custom_amount_range']['minimum'] ) |
|
340 | + && give_is_setting_enabled($_REQUEST['_give_custom_amount']) |
|
341 | + && give_maybe_sanitize_amount($_REQUEST['_give_set_price']) < give_maybe_sanitize_amount($_REQUEST['_give_custom_amount_range']['minimum']) |
|
342 | 342 | ) { |
343 | - give_update_meta( $post_id, '_give_custom_amount_range_minimum', give_sanitize_amount_for_db( $_REQUEST['_give_set_price'] ) ); |
|
343 | + give_update_meta($post_id, '_give_custom_amount_range_minimum', give_sanitize_amount_for_db($_REQUEST['_give_set_price'])); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | -add_action( 'save_post', 'give_price_save_quick_edit' ); |
|
347 | +add_action('save_post', 'give_price_save_quick_edit'); |
|
348 | 348 | |
349 | 349 | /** |
350 | 350 | * Process bulk edit actions via AJAX |
@@ -354,18 +354,18 @@ discard block |
||
354 | 354 | */ |
355 | 355 | function give_save_bulk_edit() { |
356 | 356 | |
357 | - $post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array(); |
|
357 | + $post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array(); |
|
358 | 358 | |
359 | - if ( ! empty( $post_ids ) && is_array( $post_ids ) ) { |
|
360 | - $price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0; |
|
361 | - foreach ( $post_ids as $post_id ) { |
|
359 | + if ( ! empty($post_ids) && is_array($post_ids)) { |
|
360 | + $price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0; |
|
361 | + foreach ($post_ids as $post_id) { |
|
362 | 362 | |
363 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
363 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
364 | 364 | continue; |
365 | 365 | } |
366 | 366 | |
367 | - if ( ! empty( $price ) ) { |
|
368 | - give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( $price ) ); |
|
367 | + if ( ! empty($price)) { |
|
368 | + give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db($price)); |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | } |
@@ -373,4 +373,4 @@ discard block |
||
373 | 373 | die(); |
374 | 374 | } |
375 | 375 | |
376 | -add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' ); |
|
376 | +add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit'); |
@@ -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_Page' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Page')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Page. |
@@ -70,25 +70,25 @@ discard block |
||
70 | 70 | // Get current setting page. |
71 | 71 | $this->current_setting_page = give_get_current_setting_page(); |
72 | 72 | |
73 | - add_filter( "give_default_setting_tab_section_{$this->id}", array( $this, 'set_default_setting_tab' ), 10 ); |
|
74 | - add_filter( "{$this->current_setting_page}_tabs_array", array( $this, 'add_settings_page' ), 20 ); |
|
75 | - add_action( "{$this->current_setting_page}_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
73 | + add_filter("give_default_setting_tab_section_{$this->id}", array($this, 'set_default_setting_tab'), 10); |
|
74 | + add_filter("{$this->current_setting_page}_tabs_array", array($this, 'add_settings_page'), 20); |
|
75 | + add_action("{$this->current_setting_page}_settings_{$this->id}_page", array($this, 'output')); |
|
76 | 76 | |
77 | 77 | // Output section only if exist. |
78 | 78 | $sections = $this->get_sections(); |
79 | - if ( ! empty( $sections ) ) { |
|
80 | - add_action( "{$this->current_setting_page}_sections_{$this->id}_page", array( |
|
79 | + if ( ! empty($sections)) { |
|
80 | + add_action("{$this->current_setting_page}_sections_{$this->id}_page", array( |
|
81 | 81 | $this, |
82 | 82 | 'output_sections', |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // Save hide button by default. |
87 | 87 | $GLOBALS['give_hide_save_button'] = true; |
88 | 88 | |
89 | 89 | // Enable saving feature. |
90 | - if ( $this->enable_save ) { |
|
91 | - add_action( "{$this->current_setting_page}_save_{$this->id}", array( $this, 'save' ) ); |
|
90 | + if ($this->enable_save) { |
|
91 | + add_action("{$this->current_setting_page}_save_{$this->id}", array($this, 'save')); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - function set_default_setting_tab( $setting_tab ) { |
|
116 | + function set_default_setting_tab($setting_tab) { |
|
117 | 117 | return $this->default_tab; |
118 | 118 | } |
119 | 119 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return array |
128 | 128 | */ |
129 | - public function add_settings_page( $pages ) { |
|
130 | - $pages[ $this->id ] = $this->label; |
|
129 | + public function add_settings_page($pages) { |
|
130 | + $pages[$this->id] = $this->label; |
|
131 | 131 | |
132 | 132 | return $pages; |
133 | 133 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param array $settings |
148 | 148 | */ |
149 | - $settings = apply_filters( 'give_get_settings_' . $this->id, array() ); |
|
149 | + $settings = apply_filters('give_get_settings_'.$this->id, array()); |
|
150 | 150 | |
151 | 151 | // Output. |
152 | 152 | return $settings; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @return array |
160 | 160 | */ |
161 | 161 | public function get_sections() { |
162 | - return apply_filters( 'give_get_sections_' . $this->id, array() ); |
|
162 | + return apply_filters('give_get_sections_'.$this->id, array()); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -176,40 +176,40 @@ discard block |
||
176 | 176 | $sections = $this->get_sections(); |
177 | 177 | |
178 | 178 | // Bailout. |
179 | - if ( empty( $sections ) ) { |
|
179 | + if (empty($sections)) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
183 | 183 | // Show section settings only if setting section exist. |
184 | - if ( $current_section && ! in_array( $current_section, array_keys( $sections ), true ) ) { |
|
185 | - echo wp_kses_post( '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>' ); |
|
184 | + if ($current_section && ! in_array($current_section, array_keys($sections), true)) { |
|
185 | + echo wp_kses_post('<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'); |
|
186 | 186 | $GLOBALS['give_hide_save_button'] = true; |
187 | 187 | |
188 | 188 | return; |
189 | 189 | } |
190 | 190 | |
191 | - if ( is_null( $this->current_setting_page ) ) { |
|
191 | + if (is_null($this->current_setting_page)) { |
|
192 | 192 | $this->current_setting_page = give_get_current_setting_page(); |
193 | 193 | } |
194 | 194 | |
195 | 195 | $section_list = array(); |
196 | - foreach ( $sections as $id => $label ) { |
|
196 | + foreach ($sections as $id => $label) { |
|
197 | 197 | /** |
198 | 198 | * Fire the filter to hide particular section on tab. |
199 | 199 | * |
200 | 200 | * @since 2.0 |
201 | 201 | */ |
202 | - if ( apply_filters( "give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id ) ) { |
|
202 | + if (apply_filters("give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id)) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
206 | - $section_list[] = '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=' . $this->current_setting_page . '&tab=' . $this->id . '§ion=' . sanitize_title( $id ) ) . '" class="' . ( $current_section === $id ? 'current' : '' ) . '">' . $label . '</a>'; |
|
206 | + $section_list[] = '<li><a href="'.admin_url('edit.php?post_type=give_forms&page='.$this->current_setting_page.'&tab='.$this->id.'§ion='.sanitize_title($id)).'" class="'.($current_section === $id ? 'current' : '').'">'.$label.'</a>'; |
|
207 | 207 | } |
208 | 208 | |
209 | - echo wp_kses_post( sprintf( |
|
209 | + echo wp_kses_post(sprintf( |
|
210 | 210 | '<ul class="give-subsubsub">%s</ul><br class="clear" /><hr>', |
211 | - implode( ' | </li>', $section_list ) |
|
212 | - ) ); |
|
211 | + implode(' | </li>', $section_list) |
|
212 | + )); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | * @return void |
222 | 222 | */ |
223 | 223 | public function output() { |
224 | - if ( $this->enable_save ) { |
|
224 | + if ($this->enable_save) { |
|
225 | 225 | $GLOBALS['give_hide_save_button'] = false; |
226 | 226 | } |
227 | 227 | |
228 | 228 | $settings = $this->get_settings(); |
229 | 229 | |
230 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
230 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @since 2.1 |
247 | 247 | */ |
248 | - if ( apply_filters( "give_save_options_{$this->id}_{$current_section}", true ) ) { |
|
249 | - Give_Admin_Settings::save_fields( $settings, 'give_settings' ); |
|
248 | + if (apply_filters("give_save_options_{$this->id}_{$current_section}", true)) { |
|
249 | + Give_Admin_Settings::save_fields($settings, 'give_settings'); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @since 1.8 |
256 | 256 | */ |
257 | - do_action( 'give_update_options_' . $this->id . '_' . $current_section ); |
|
257 | + do_action('give_update_options_'.$this->id.'_'.$current_section); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | $section = $this->get_sections(); |
272 | 272 | $current_section = give_get_current_setting_section(); |
273 | 273 | |
274 | - if ( array_key_exists( $current_section, $section ) ) { |
|
275 | - $heading[] = $section[ $current_section ]; |
|
274 | + if (array_key_exists($current_section, $section)) { |
|
275 | + $heading[] = $section[$current_section]; |
|
276 | 276 | } |
277 | 277 | |
278 | - return array_unique( $heading ); |
|
278 | + return array_unique($heading); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | public function get_heading_html() { |
290 | 290 | return sprintf( |
291 | 291 | '<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">', |
292 | - implode( ' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading() ) |
|
292 | + implode(' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading()) |
|
293 | 293 | ); |
294 | 294 | } |
295 | 295 | } |
@@ -19,28 +19,28 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return array |
21 | 21 | */ |
22 | -function give_email_notification_row_actions_callback( $row_actions, $email ) { |
|
23 | - if( Give_Email_Notification_Util::is_email_preview( $email ) ) { |
|
22 | +function give_email_notification_row_actions_callback($row_actions, $email) { |
|
23 | + if (Give_Email_Notification_Util::is_email_preview($email)) { |
|
24 | 24 | $preview_link = sprintf( |
25 | 25 | '<a href="%1$s" target="_blank">%2$s</a>', |
26 | 26 | wp_nonce_url( |
27 | 27 | add_query_arg( |
28 | - array( 'give_action' => 'preview_email', 'email_type' => $email->config['id'] ), |
|
28 | + array('give_action' => 'preview_email', 'email_type' => $email->config['id']), |
|
29 | 29 | home_url() |
30 | 30 | ), 'give-preview-email' |
31 | 31 | ), |
32 | - __( 'Preview', 'give' ) |
|
32 | + __('Preview', 'give') |
|
33 | 33 | ); |
34 | 34 | |
35 | 35 | $send_preview_email_link = sprintf( |
36 | 36 | '<a href="%1$s">%2$s</a>', |
37 | 37 | wp_nonce_url( |
38 | - add_query_arg( array( |
|
38 | + add_query_arg(array( |
|
39 | 39 | 'give_action' => 'send_preview_email', |
40 | 40 | 'email_type' => $email->config['id'], |
41 | 41 | 'give-messages[]' => 'sent-test-email', |
42 | - ) ), 'give-send-preview-email' ), |
|
43 | - __( 'Send test email', 'give' ) |
|
42 | + )), 'give-send-preview-email' ), |
|
43 | + __('Send test email', 'give') |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | $row_actions['email_preview'] = $preview_link; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | return $row_actions; |
51 | 51 | } |
52 | -add_filter( 'give_email_notification_row_actions', 'give_email_notification_row_actions_callback', 10, 2 ); |
|
52 | +add_filter('give_email_notification_row_actions', 'give_email_notification_row_actions_callback', 10, 2); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * This help to decode all email template tags. |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return string |
63 | 63 | */ |
64 | -function give_decode_email_tags( $message, $email_obj ) { |
|
65 | - if ( ! empty( $email_obj->tag_args ) ) { |
|
66 | - $message = give_do_email_tags( $message, $email_obj->tag_args ); |
|
64 | +function give_decode_email_tags($message, $email_obj) { |
|
65 | + if ( ! empty($email_obj->tag_args)) { |
|
66 | + $message = give_do_email_tags($message, $email_obj->tag_args); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | return $message; |
70 | 70 | } |
71 | 71 | |
72 | -add_filter( 'give_email_message', 'give_decode_email_tags', 10, 2 ); |
|
73 | 72 | \ No newline at end of file |
73 | +add_filter('give_email_message', 'give_decode_email_tags', 10, 2); |
|
74 | 74 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
39 | - add_filter( 'woocommerce_disable_admin_bar', array( $this, 'manage_admin_dashboard' ), 10, 1 ); |
|
40 | - add_filter( 'woocommerce_prevent_admin_access', array( $this, 'manage_admin_dashboard' ), 10 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | + add_filter('woocommerce_disable_admin_bar', array($this, 'manage_admin_dashboard'), 10, 1); |
|
40 | + add_filter('woocommerce_prevent_admin_access', array($this, 'manage_admin_dashboard'), 10); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return void |
52 | 52 | */ |
53 | 53 | public function add_roles() { |
54 | - add_role( 'give_manager', __( 'Give Manager', 'give' ), array( |
|
54 | + add_role('give_manager', __('Give Manager', 'give'), array( |
|
55 | 55 | 'read' => true, |
56 | 56 | 'edit_posts' => true, |
57 | 57 | 'delete_posts' => true, |
@@ -80,25 +80,25 @@ discard block |
||
80 | 80 | 'publish_posts' => true, |
81 | 81 | 'read_private_pages' => true, |
82 | 82 | 'read_private_posts' => true, |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | |
85 | - add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array( |
|
85 | + add_role('give_accountant', __('Give Accountant', 'give'), array( |
|
86 | 86 | 'read' => true, |
87 | 87 | 'edit_posts' => false, |
88 | 88 | 'delete_posts' => false, |
89 | - ) ); |
|
89 | + )); |
|
90 | 90 | |
91 | - add_role( 'give_worker', __( 'Give Worker', 'give' ), array( |
|
91 | + add_role('give_worker', __('Give Worker', 'give'), array( |
|
92 | 92 | 'read' => true, |
93 | 93 | 'edit_posts' => true, |
94 | 94 | 'edit_pages' => true, |
95 | 95 | 'upload_files' => true, |
96 | 96 | 'delete_posts' => false, |
97 | - ) ); |
|
97 | + )); |
|
98 | 98 | |
99 | - add_role( 'give_donor', __( 'Give Donor', 'give' ), array( |
|
99 | + add_role('give_donor', __('Give Donor', 'give'), array( |
|
100 | 100 | 'read' => true, |
101 | - ) ); |
|
101 | + )); |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
@@ -117,54 +117,54 @@ discard block |
||
117 | 117 | public function add_caps() { |
118 | 118 | global $wp_roles; |
119 | 119 | |
120 | - if ( class_exists( 'WP_Roles' ) ) { |
|
121 | - if ( ! isset( $wp_roles ) ) { |
|
120 | + if (class_exists('WP_Roles')) { |
|
121 | + if ( ! isset($wp_roles)) { |
|
122 | 122 | $wp_roles = new WP_Roles(); |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if ( is_object( $wp_roles ) ) { |
|
127 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
129 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
130 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
131 | - $wp_roles->add_cap( 'give_manager', 'view_give_payments' ); |
|
126 | + if (is_object($wp_roles)) { |
|
127 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
128 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
129 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
130 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
131 | + $wp_roles->add_cap('give_manager', 'view_give_payments'); |
|
132 | 132 | |
133 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
134 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
135 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
136 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
137 | - $wp_roles->add_cap( 'administrator', 'view_give_payments' ); |
|
133 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
134 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
135 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
136 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
137 | + $wp_roles->add_cap('administrator', 'view_give_payments'); |
|
138 | 138 | |
139 | 139 | // Add the main post type capabilities. |
140 | 140 | $capabilities = $this->get_core_caps(); |
141 | - foreach ( $capabilities as $cap_group ) { |
|
142 | - foreach ( $cap_group as $cap ) { |
|
143 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
144 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
141 | + foreach ($capabilities as $cap_group) { |
|
142 | + foreach ($cap_group as $cap) { |
|
143 | + $wp_roles->add_cap('administrator', $cap); |
|
144 | + $wp_roles->add_cap('give_manager', $cap); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Add Capabilities to Give Workers User Role. |
149 | - $wp_roles->add_cap( 'give_worker', 'edit_give_payments' ); |
|
150 | - $wp_roles->add_cap( 'give_worker', 'delete_give_forms' ); |
|
151 | - $wp_roles->add_cap( 'give_worker', 'delete_others_give_forms' ); |
|
152 | - $wp_roles->add_cap( 'give_worker', 'delete_private_give_forms' ); |
|
153 | - $wp_roles->add_cap( 'give_worker', 'delete_published_give_forms' ); |
|
154 | - $wp_roles->add_cap( 'give_worker', 'edit_give_forms' ); |
|
155 | - $wp_roles->add_cap( 'give_worker', 'edit_others_give_forms' ); |
|
156 | - $wp_roles->add_cap( 'give_worker', 'edit_private_give_forms' ); |
|
157 | - $wp_roles->add_cap( 'give_worker', 'edit_published_give_forms' ); |
|
158 | - $wp_roles->add_cap( 'give_worker', 'publish_give_forms' ); |
|
159 | - $wp_roles->add_cap( 'give_worker', 'read_private_give_forms' ); |
|
149 | + $wp_roles->add_cap('give_worker', 'edit_give_payments'); |
|
150 | + $wp_roles->add_cap('give_worker', 'delete_give_forms'); |
|
151 | + $wp_roles->add_cap('give_worker', 'delete_others_give_forms'); |
|
152 | + $wp_roles->add_cap('give_worker', 'delete_private_give_forms'); |
|
153 | + $wp_roles->add_cap('give_worker', 'delete_published_give_forms'); |
|
154 | + $wp_roles->add_cap('give_worker', 'edit_give_forms'); |
|
155 | + $wp_roles->add_cap('give_worker', 'edit_others_give_forms'); |
|
156 | + $wp_roles->add_cap('give_worker', 'edit_private_give_forms'); |
|
157 | + $wp_roles->add_cap('give_worker', 'edit_published_give_forms'); |
|
158 | + $wp_roles->add_cap('give_worker', 'publish_give_forms'); |
|
159 | + $wp_roles->add_cap('give_worker', 'read_private_give_forms'); |
|
160 | 160 | |
161 | 161 | // Add Capabilities to Give Accountant User Role. |
162 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
163 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
164 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
165 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
166 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
167 | - $wp_roles->add_cap( 'give_accountant', 'view_give_payments' ); |
|
162 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
163 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
164 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
165 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
166 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
167 | + $wp_roles->add_cap('give_accountant', 'view_give_payments'); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | public function get_core_caps() { |
183 | 183 | $capabilities = array(); |
184 | 184 | |
185 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
185 | + $capability_types = array('give_form', 'give_payment'); |
|
186 | 186 | |
187 | - foreach ( $capability_types as $capability_type ) { |
|
188 | - $capabilities[ $capability_type ] = array( |
|
187 | + foreach ($capability_types as $capability_type) { |
|
188 | + $capabilities[$capability_type] = array( |
|
189 | 189 | // Post type. |
190 | 190 | "edit_{$capability_type}", |
191 | 191 | "read_{$capability_type}", |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return array $caps Meta capabilities. |
233 | 233 | */ |
234 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
234 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
235 | 235 | |
236 | - switch ( $cap ) { |
|
236 | + switch ($cap) { |
|
237 | 237 | |
238 | 238 | case 'view_give_form_stats' : |
239 | 239 | |
240 | - if ( empty( $args[0] ) ) { |
|
240 | + if (empty($args[0])) { |
|
241 | 241 | break; |
242 | 242 | } |
243 | 243 | |
244 | - $form = get_post( $args[0] ); |
|
245 | - if ( empty( $form ) ) { |
|
244 | + $form = get_post($args[0]); |
|
245 | + if (empty($form)) { |
|
246 | 246 | break; |
247 | 247 | } |
248 | 248 | |
249 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
249 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
250 | 250 | $caps = array(); |
251 | 251 | } |
252 | 252 | |
@@ -273,57 +273,57 @@ discard block |
||
273 | 273 | |
274 | 274 | global $wp_roles; |
275 | 275 | |
276 | - if ( class_exists( 'WP_Roles' ) ) { |
|
277 | - if ( ! isset( $wp_roles ) ) { |
|
276 | + if (class_exists('WP_Roles')) { |
|
277 | + if ( ! isset($wp_roles)) { |
|
278 | 278 | $wp_roles = new WP_Roles(); |
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | - if ( is_object( $wp_roles ) ) { |
|
282 | + if (is_object($wp_roles)) { |
|
283 | 283 | // Give Manager Capabilities. |
284 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
285 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
286 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
287 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
284 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
285 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
286 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
287 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
288 | 288 | |
289 | 289 | // Site Administrator Capabilities. |
290 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
291 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
292 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
293 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
294 | - $wp_roles->remove_cap( 'administrator', 'view_give_payments' ); |
|
290 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
291 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
292 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
293 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
294 | + $wp_roles->remove_cap('administrator', 'view_give_payments'); |
|
295 | 295 | |
296 | 296 | // Remove the Main Post Type Capabilities. |
297 | 297 | $capabilities = $this->get_core_caps(); |
298 | 298 | |
299 | - foreach ( $capabilities as $cap_group ) { |
|
300 | - foreach ( $cap_group as $cap ) { |
|
301 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
302 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
299 | + foreach ($capabilities as $cap_group) { |
|
300 | + foreach ($cap_group as $cap) { |
|
301 | + $wp_roles->remove_cap('give_manager', $cap); |
|
302 | + $wp_roles->remove_cap('administrator', $cap); |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | 307 | // Remove capabilities from the Give Worker role. |
308 | - $wp_roles->remove_cap( 'give_worker', 'edit_give_payments' ); |
|
309 | - $wp_roles->remove_cap( 'give_worker', 'delete_give_forms' ); |
|
310 | - $wp_roles->remove_cap( 'give_worker', 'delete_others_give_forms' ); |
|
311 | - $wp_roles->remove_cap( 'give_worker', 'delete_private_give_forms' ); |
|
312 | - $wp_roles->remove_cap( 'give_worker', 'delete_published_give_forms' ); |
|
313 | - $wp_roles->remove_cap( 'give_worker', 'edit_give_forms' ); |
|
314 | - $wp_roles->remove_cap( 'give_worker', 'edit_others_give_forms' ); |
|
315 | - $wp_roles->remove_cap( 'give_worker', 'edit_private_give_forms' ); |
|
316 | - $wp_roles->remove_cap( 'give_worker', 'edit_published_give_forms' ); |
|
317 | - $wp_roles->remove_cap( 'give_worker', 'publish_give_forms' ); |
|
318 | - $wp_roles->remove_cap( 'give_worker', 'read_private_give_forms' ); |
|
308 | + $wp_roles->remove_cap('give_worker', 'edit_give_payments'); |
|
309 | + $wp_roles->remove_cap('give_worker', 'delete_give_forms'); |
|
310 | + $wp_roles->remove_cap('give_worker', 'delete_others_give_forms'); |
|
311 | + $wp_roles->remove_cap('give_worker', 'delete_private_give_forms'); |
|
312 | + $wp_roles->remove_cap('give_worker', 'delete_published_give_forms'); |
|
313 | + $wp_roles->remove_cap('give_worker', 'edit_give_forms'); |
|
314 | + $wp_roles->remove_cap('give_worker', 'edit_others_give_forms'); |
|
315 | + $wp_roles->remove_cap('give_worker', 'edit_private_give_forms'); |
|
316 | + $wp_roles->remove_cap('give_worker', 'edit_published_give_forms'); |
|
317 | + $wp_roles->remove_cap('give_worker', 'publish_give_forms'); |
|
318 | + $wp_roles->remove_cap('give_worker', 'read_private_give_forms'); |
|
319 | 319 | |
320 | 320 | // Remove Capabilities from Give Accountant User Role. |
321 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
322 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
323 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
324 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
325 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_payments' ); |
|
326 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_payments' ); |
|
321 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
322 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
323 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
324 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
325 | + $wp_roles->remove_cap('give_accountant', 'edit_give_payments'); |
|
326 | + $wp_roles->remove_cap('give_accountant', 'view_give_payments'); |
|
327 | 327 | |
328 | 328 | } |
329 | 329 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $current_user = wp_get_current_user(); |
347 | 347 | |
348 | 348 | // If user with "Give Accountant" user role is logged-in . |
349 | - if ( 0 !== $current_user->ID && in_array( 'give_accountant', (array) $current_user->roles, true ) ) { |
|
349 | + if (0 !== $current_user->ID && in_array('give_accountant', (array) $current_user->roles, true)) { |
|
350 | 350 | |
351 | 351 | // Return false, means no prevention. |
352 | 352 | return false; |
@@ -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 | |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function __construct() { |
104 | 104 | |
105 | - if ( 'none' === $this->get_template() ) { |
|
105 | + if ('none' === $this->get_template()) { |
|
106 | 106 | $this->html = false; |
107 | 107 | } |
108 | 108 | |
109 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
110 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
109 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
110 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param $key |
120 | 120 | * @param $value |
121 | 121 | */ |
122 | - public function __set( $key, $value ) { |
|
122 | + public function __set($key, $value) { |
|
123 | 123 | $this->$key = $value; |
124 | 124 | } |
125 | 125 | |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | 131 | public function get_from_name() { |
132 | - if ( ! $this->from_name ) { |
|
133 | - $this->from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
132 | + if ( ! $this->from_name) { |
|
133 | + $this->from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
134 | 134 | } |
135 | 135 | |
136 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
136 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @since 1.0 |
143 | 143 | */ |
144 | 144 | public function get_from_address() { |
145 | - if ( ! $this->from_address ) { |
|
146 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
145 | + if ( ! $this->from_address) { |
|
146 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
147 | 147 | } |
148 | 148 | |
149 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
149 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * @since 1.0 |
156 | 156 | */ |
157 | 157 | public function get_content_type() { |
158 | - if ( ! $this->content_type ) { |
|
158 | + if ( ! $this->content_type) { |
|
159 | 159 | $this->content_type = $this->html |
160 | - ? apply_filters( 'give_email_default_content_type', 'text/html', $this ) |
|
160 | + ? apply_filters('give_email_default_content_type', 'text/html', $this) |
|
161 | 161 | : 'text/plain'; |
162 | 162 | } |
163 | 163 | |
164 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
164 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | * @since 1.0 |
171 | 171 | */ |
172 | 172 | public function get_headers() { |
173 | - if ( ! $this->headers ) { |
|
173 | + if ( ! $this->headers) { |
|
174 | 174 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
175 | 175 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
176 | 176 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
177 | 177 | } |
178 | 178 | |
179 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
179 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function get_templates() { |
188 | 188 | $templates = array( |
189 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
190 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
189 | + 'default' => esc_html__('Default Template', 'give'), |
|
190 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
191 | 191 | ); |
192 | 192 | |
193 | - return apply_filters( 'give_email_templates', $templates ); |
|
193 | + return apply_filters('give_email_templates', $templates); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @since 1.0 |
200 | 200 | */ |
201 | 201 | public function get_template() { |
202 | - if ( ! $this->template ) { |
|
203 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
202 | + if ( ! $this->template) { |
|
203 | + $this->template = give_get_option('email_template', 'default'); |
|
204 | 204 | } |
205 | 205 | |
206 | - return apply_filters( 'give_email_template', $this->template ); |
|
206 | + return apply_filters('give_email_template', $this->template); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @since 1.0 |
213 | 213 | */ |
214 | 214 | public function get_heading() { |
215 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
215 | + return apply_filters('give_email_heading', $this->heading); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return mixed |
224 | 224 | */ |
225 | - public function parse_tags( $content ) { |
|
225 | + public function parse_tags($content) { |
|
226 | 226 | return $content; |
227 | 227 | } |
228 | 228 | |
@@ -235,34 +235,34 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public function build_email( $message ) { |
|
238 | + public function build_email($message) { |
|
239 | 239 | |
240 | - if ( false === $this->html ) { |
|
240 | + if (false === $this->html) { |
|
241 | 241 | |
242 | 242 | // Added Replacement check to simply behaviour of anchor tags. |
243 | 243 | $pattern = '/<a.+?href\=(?:["|\'])(.+?)(?:["|\']).*?>(.+?)<\/a>/i'; |
244 | 244 | $message = preg_replace_callback( |
245 | 245 | $pattern, |
246 | - function ( $return ) { |
|
247 | - if ( $return[1] !== $return[2] ) { |
|
246 | + function($return) { |
|
247 | + if ($return[1] !== $return[2]) { |
|
248 | 248 | return "{$return[2]} ( {$return[1]} )"; |
249 | 249 | } |
250 | 250 | |
251 | - return trailingslashit( $return[1] ); |
|
251 | + return trailingslashit($return[1]); |
|
252 | 252 | }, |
253 | 253 | $message |
254 | 254 | ); |
255 | 255 | |
256 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
256 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
257 | 257 | } |
258 | 258 | |
259 | - $message = $this->text_to_html( $message ); |
|
259 | + $message = $this->text_to_html($message); |
|
260 | 260 | |
261 | 261 | $template = $this->get_template(); |
262 | 262 | |
263 | 263 | ob_start(); |
264 | 264 | |
265 | - give_get_template_part( 'emails/header', $template, true ); |
|
265 | + give_get_template_part('emails/header', $template, true); |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Fires in the email head. |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @param Give_Emails $this The email object. |
273 | 273 | */ |
274 | - do_action( 'give_email_header', $this ); |
|
274 | + do_action('give_email_header', $this); |
|
275 | 275 | |
276 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
276 | + if (has_action('give_email_template_'.$template)) { |
|
277 | 277 | /** |
278 | 278 | * Fires in a specific email template. |
279 | 279 | * |
280 | 280 | * @since 1.0 |
281 | 281 | */ |
282 | - do_action( "give_email_template_{$template}" ); |
|
282 | + do_action("give_email_template_{$template}"); |
|
283 | 283 | } else { |
284 | - give_get_template_part( 'emails/body', $template, true ); |
|
284 | + give_get_template_part('emails/body', $template, true); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @param Give_Emails $this The email object. |
293 | 293 | */ |
294 | - do_action( 'give_email_body', $this ); |
|
294 | + do_action('give_email_body', $this); |
|
295 | 295 | |
296 | - give_get_template_part( 'emails/footer', $template, true ); |
|
296 | + give_get_template_part('emails/footer', $template, true); |
|
297 | 297 | |
298 | 298 | /** |
299 | 299 | * Fires in the email footer. |
@@ -302,26 +302,26 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @param Give_Emails $this The email object. |
304 | 304 | */ |
305 | - do_action( 'give_email_footer', $this ); |
|
305 | + do_action('give_email_footer', $this); |
|
306 | 306 | |
307 | 307 | $body = ob_get_clean(); |
308 | 308 | |
309 | 309 | // Email tag. |
310 | - $message = str_replace( '{email}', $message, $body ); |
|
310 | + $message = str_replace('{email}', $message, $body); |
|
311 | 311 | |
312 | - $header_img = Give_Email_Notification_Util::get_email_logo( $this->form_id ); |
|
312 | + $header_img = Give_Email_Notification_Util::get_email_logo($this->form_id); |
|
313 | 313 | |
314 | - if ( ! empty( $header_img ) ) { |
|
314 | + if ( ! empty($header_img)) { |
|
315 | 315 | $header_img = sprintf( |
316 | 316 | '<div id="template_header_image"><p style="margin-top:0;"><img style="max-width:450px;" src="%1$s" alt="%2$s" /></p></div>', |
317 | - esc_url( $header_img ), |
|
318 | - get_bloginfo( 'name' ) |
|
317 | + esc_url($header_img), |
|
318 | + get_bloginfo('name') |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | |
322 | - $message = str_replace( '{email_logo}', $header_img, $message ); |
|
322 | + $message = str_replace('{email_logo}', $header_img, $message); |
|
323 | 323 | |
324 | - return apply_filters( 'give_email_message', $message, $this ); |
|
324 | + return apply_filters('give_email_message', $message, $this); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return bool |
336 | 336 | */ |
337 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
337 | + public function send($to, $subject, $message, $attachments = '') { |
|
338 | 338 | |
339 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
340 | - give_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
339 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
340 | + give_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
341 | 341 | |
342 | 342 | return false; |
343 | 343 | } |
@@ -349,16 +349,16 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @param Give_Emails $this The email object. |
351 | 351 | */ |
352 | - do_action( 'give_email_send_before', $this ); |
|
352 | + do_action('give_email_send_before', $this); |
|
353 | 353 | |
354 | - $subject = $this->parse_tags( $subject ); |
|
355 | - $message = $this->parse_tags( $message ); |
|
354 | + $subject = $this->parse_tags($subject); |
|
355 | + $message = $this->parse_tags($message); |
|
356 | 356 | |
357 | - $message = $this->build_email( $message ); |
|
357 | + $message = $this->build_email($message); |
|
358 | 358 | |
359 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
359 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
360 | 360 | |
361 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
361 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Fires after sending an email. |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @param Give_Emails $this The email object. |
369 | 369 | */ |
370 | - do_action( 'give_email_send_after', $this ); |
|
370 | + do_action('give_email_send_after', $this); |
|
371 | 371 | |
372 | 372 | return $sent; |
373 | 373 | |
@@ -379,9 +379,9 @@ discard block |
||
379 | 379 | * @since 1.0 |
380 | 380 | */ |
381 | 381 | public function send_before() { |
382 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
383 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
384 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
382 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
383 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
384 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -390,9 +390,9 @@ discard block |
||
390 | 390 | * @since 1.0 |
391 | 391 | */ |
392 | 392 | public function send_after() { |
393 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
394 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
395 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
393 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
394 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
395 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
396 | 396 | |
397 | 397 | // Reset email related params. |
398 | 398 | $this->heading = ''; |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @since 1.0 |
408 | 408 | */ |
409 | - public function text_to_html( $message ) { |
|
409 | + public function text_to_html($message) { |
|
410 | 410 | |
411 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
412 | - $message = wpautop( $message ); |
|
411 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
412 | + $message = wpautop($message); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | return $message; |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* @var Give_Updates $give_updates */ |
3 | -$plugins = $give_updates->get_updates( 'plugin' ); |
|
4 | -if ( empty( $plugins ) ) { |
|
3 | +$plugins = $give_updates->get_updates('plugin'); |
|
4 | +if (empty($plugins)) { |
|
5 | 5 | return; |
6 | 6 | } |
7 | 7 | |
8 | 8 | ob_start(); |
9 | -foreach ( $plugins as $plugin_data ) { |
|
10 | - if ( 'active' != $plugin_data['Status'] || 'add-on' != $plugin_data['Type'] ) { |
|
9 | +foreach ($plugins as $plugin_data) { |
|
10 | + if ('active' != $plugin_data['Status'] || 'add-on' != $plugin_data['Type']) { |
|
11 | 11 | continue; |
12 | 12 | } |
13 | 13 | |
@@ -15,45 +15,45 @@ discard block |
||
15 | 15 | $author_name = $plugin_data['Author']; |
16 | 16 | |
17 | 17 | // Link the plugin name to the plugin URL if available. |
18 | - if ( ! empty( $plugin_data['PluginURI'] ) ) { |
|
18 | + if ( ! empty($plugin_data['PluginURI'])) { |
|
19 | 19 | $plugin_name = sprintf( |
20 | 20 | '<a href="%s" title="%s">%s</a> (%s)', |
21 | - esc_url( $plugin_data['PluginURI'] ), |
|
22 | - esc_attr__( 'Visit plugin homepage', 'give' ), |
|
21 | + esc_url($plugin_data['PluginURI']), |
|
22 | + esc_attr__('Visit plugin homepage', 'give'), |
|
23 | 23 | $plugin_name, |
24 | - esc_html( $plugin_data['Version'] ) |
|
24 | + esc_html($plugin_data['Version']) |
|
25 | 25 | ); |
26 | 26 | } |
27 | 27 | |
28 | 28 | // Link the author name to the author URL if available. |
29 | - if ( ! empty( $plugin_data['AuthorURI'] ) ) { |
|
29 | + if ( ! empty($plugin_data['AuthorURI'])) { |
|
30 | 30 | $author_name = sprintf( |
31 | 31 | '<a href="%s" title="%s">%s</a>', |
32 | - esc_url( $plugin_data['AuthorURI'] ), |
|
33 | - esc_attr__( 'Visit author homepage', 'give' ), |
|
32 | + esc_url($plugin_data['AuthorURI']), |
|
33 | + esc_attr__('Visit author homepage', 'give'), |
|
34 | 34 | $author_name |
35 | 35 | ); |
36 | 36 | } |
37 | 37 | ?> |
38 | 38 | <tr> |
39 | - <td><?php echo wp_kses( $plugin_name, wp_kses_allowed_html( 'post' ) ); ?></td> |
|
39 | + <td><?php echo wp_kses($plugin_name, wp_kses_allowed_html('post')); ?></td> |
|
40 | 40 | <td> |
41 | 41 | <?php |
42 | 42 | echo true === $plugin_data['License'] |
43 | 43 | ? sprintf( |
44 | 44 | '<span class="dashicons dashicons-yes"></span>%s', |
45 | - __( 'Licensed', 'give' ) |
|
45 | + __('Licensed', 'give') |
|
46 | 46 | ) |
47 | 47 | : sprintf( |
48 | 48 | '<span data-tooltip="%s"><span class="dashicons dashicons-no-alt"></span>%s</span>', |
49 | - __( 'Unlicensed add-ons cannot be updated. Please purchase or renew a valid license.', 'give' ), |
|
50 | - __( 'Unlicensed', 'give' ) |
|
49 | + __('Unlicensed add-ons cannot be updated. Please purchase or renew a valid license.', 'give'), |
|
50 | + __('Unlicensed', 'give') |
|
51 | 51 | ); |
52 | 52 | |
53 | 53 | echo sprintf( |
54 | 54 | ' – %s – %s', |
55 | - sprintf( _x( 'by %s', 'by author', 'give' ), wp_kses( $author_name, wp_kses_allowed_html( 'post' ) ) ), |
|
56 | - sprintf( __( '(Latest Version: %s)' ), $plugin_data['update']->new_version ) |
|
55 | + sprintf(_x('by %s', 'by author', 'give'), wp_kses($author_name, wp_kses_allowed_html('post'))), |
|
56 | + sprintf(__('(Latest Version: %s)'), $plugin_data['update']->new_version) |
|
57 | 57 | ); |
58 | 58 | ?> |
59 | 59 | </td> |
@@ -615,8 +615,11 @@ |
||
615 | 615 | <a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn"> |
616 | 616 | <?php _e( 'Restart the updater', 'give' ); ?> |
617 | 617 | </a> |
618 | - <?php else: ?> |
|
619 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
618 | + <?php else { |
|
619 | + : ?> |
|
620 | + <strong><?php _e( 'Database Update', 'give' ); |
|
621 | +} |
|
622 | +?></strong> |
|
620 | 623 | – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
621 | 624 | <a href="<?php echo esc_url('http://docs.givewp.com/troubleshooting-db-updates')?>" target="_blank"><?php _e( 'Read More', 'give' ); ?> »</a> |
622 | 625 | <?php |
@@ -80,34 +80,34 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param array $args |
82 | 82 | */ |
83 | - public function register( $args ) { |
|
83 | + public function register($args) { |
|
84 | 84 | $args_default = array( |
85 | 85 | 'id' => '', |
86 | 86 | 'version' => '', |
87 | 87 | 'callback' => '', |
88 | 88 | ); |
89 | 89 | |
90 | - $args = wp_parse_args( $args, $args_default ); |
|
90 | + $args = wp_parse_args($args, $args_default); |
|
91 | 91 | |
92 | 92 | // You can only register database upgrade. |
93 | 93 | $args['type'] = 'database'; |
94 | 94 | |
95 | 95 | // Bailout. |
96 | 96 | if ( |
97 | - empty( $args['id'] ) || |
|
98 | - empty( $args['version'] ) || |
|
99 | - empty( $args['callback'] ) || |
|
100 | - ! is_callable( $args['callback'] ) |
|
97 | + empty($args['id']) || |
|
98 | + empty($args['version']) || |
|
99 | + empty($args['callback']) || |
|
100 | + ! is_callable($args['callback']) |
|
101 | 101 | ) { |
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Change depend param to array. |
106 | - if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) { |
|
107 | - $args['depend'] = array( $args['depend'] ); |
|
106 | + if (isset($args['depend']) && is_string($args['depend'])) { |
|
107 | + $args['depend'] = array($args['depend']); |
|
108 | 108 | } |
109 | 109 | |
110 | - $this->updates[ $args['type'] ][] = $args; |
|
110 | + $this->updates[$args['type']][] = $args; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return static |
119 | 119 | */ |
120 | 120 | static function get_instance() { |
121 | - if ( is_null( self::$instance ) ) { |
|
121 | + if (is_null(self::$instance)) { |
|
122 | 122 | self::$instance = new self(); |
123 | 123 | } |
124 | 124 | |
@@ -136,27 +136,27 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * Load file |
138 | 138 | */ |
139 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php'; |
|
140 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
139 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php'; |
|
140 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
141 | 141 | |
142 | 142 | self::$background_updater = new Give_Background_Updater(); |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Setup hooks. |
146 | 146 | */ |
147 | - add_action( 'init', array( $this, '__register_upgrade' ), 9999 ); |
|
148 | - add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 ); |
|
149 | - add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) ); |
|
150 | - add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) ); |
|
151 | - add_action( 'admin_init', array( $this, '__redirect_admin' ) ); |
|
152 | - add_action( 'admin_init', array( $this, '__pause_db_update' ), - 1 ); |
|
153 | - add_action( 'admin_init', array( $this, '__restart_db_update' ), - 1 ); |
|
154 | - add_action( 'admin_notices', array( $this, '__show_notice' ) ); |
|
155 | - add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) ); |
|
156 | - |
|
157 | - if ( is_admin() ) { |
|
158 | - add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 ); |
|
159 | - add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 ); |
|
147 | + add_action('init', array($this, '__register_upgrade'), 9999); |
|
148 | + add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999); |
|
149 | + add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info')); |
|
150 | + add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating')); |
|
151 | + add_action('admin_init', array($this, '__redirect_admin')); |
|
152 | + add_action('admin_init', array($this, '__pause_db_update'), - 1); |
|
153 | + add_action('admin_init', array($this, '__restart_db_update'), - 1); |
|
154 | + add_action('admin_notices', array($this, '__show_notice')); |
|
155 | + add_action('give_restart_db_upgrade', array($this, '__health_background_update')); |
|
156 | + |
|
157 | + if (is_admin()) { |
|
158 | + add_action('admin_init', array($this, '__change_donations_label'), 9999); |
|
159 | + add_action('admin_menu', array($this, '__register_menu'), 9999); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | $addons = give_get_plugins(); |
171 | 171 | $plugin_updates = get_plugin_updates(); |
172 | 172 | |
173 | - foreach ( $addons as $key => $info ) { |
|
174 | - if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) { |
|
173 | + foreach ($addons as $key => $info) { |
|
174 | + if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) { |
|
175 | 175 | continue; |
176 | 176 | } |
177 | 177 | |
178 | - $this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] ); |
|
178 | + $this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @access public |
188 | 188 | */ |
189 | 189 | public function __register_upgrade() { |
190 | - if ( ! is_admin() ) { |
|
190 | + if ( ! is_admin()) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @since 1.8.12 |
198 | 198 | */ |
199 | - do_action( 'give_register_updates', $this ); |
|
199 | + do_action('give_register_updates', $this); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -209,23 +209,22 @@ discard block |
||
209 | 209 | global $menu; |
210 | 210 | |
211 | 211 | // Bailout. |
212 | - if ( empty( $menu ) || ! $this->get_total_update_count() ) { |
|
212 | + if (empty($menu) || ! $this->get_total_update_count()) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
216 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
217 | 217 | |
218 | - foreach ( $menu as $index => $menu_item ) { |
|
219 | - if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) { |
|
218 | + foreach ($menu as $index => $menu_item) { |
|
219 | + if ('edit.php?post_type=give_forms' !== $menu_item[2]) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | - $menu[ $index ][0] = sprintf( |
|
223 | + $menu[$index][0] = sprintf( |
|
224 | 224 | '%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>', |
225 | - __( 'Donations', 'give' ), |
|
225 | + __('Donations', 'give'), |
|
226 | 226 | $is_update ? |
227 | - $this->get_db_update_processing_percentage() : |
|
228 | - $this->get_total_update_count(), |
|
227 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
229 | 228 | $is_update ? '%' : '' |
230 | 229 | ); |
231 | 230 | |
@@ -244,41 +243,40 @@ discard block |
||
244 | 243 | $this->__register_plugin_addon_updates(); |
245 | 244 | |
246 | 245 | // Bailout. |
247 | - if ( ! $this->get_total_update_count() ) { |
|
246 | + if ( ! $this->get_total_update_count()) { |
|
248 | 247 | // Show complete update message if still on update setting page. |
249 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
248 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
250 | 249 | // Upgrades |
251 | 250 | add_submenu_page( |
252 | 251 | 'edit.php?post_type=give_forms', |
253 | - esc_html__( 'Give Updates Complete', 'give' ), |
|
254 | - __( 'Updates', 'give' ), |
|
252 | + esc_html__('Give Updates Complete', 'give'), |
|
253 | + __('Updates', 'give'), |
|
255 | 254 | 'manage_give_settings', |
256 | 255 | 'give-updates', |
257 | - array( $this, 'render_complete_page' ) |
|
256 | + array($this, 'render_complete_page') |
|
258 | 257 | ); |
259 | 258 | } |
260 | 259 | |
261 | 260 | return; |
262 | 261 | } |
263 | 262 | |
264 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
263 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
265 | 264 | |
266 | 265 | // Upgrades |
267 | 266 | add_submenu_page( |
268 | 267 | 'edit.php?post_type=give_forms', |
269 | - esc_html__( 'Give Updates', 'give' ), |
|
268 | + esc_html__('Give Updates', 'give'), |
|
270 | 269 | sprintf( |
271 | 270 | '%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>', |
272 | - __( 'Updates', 'give' ), |
|
273 | - isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '', |
|
271 | + __('Updates', 'give'), |
|
272 | + isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '', |
|
274 | 273 | $is_update ? |
275 | - $this->get_db_update_processing_percentage() : |
|
276 | - $this->get_total_update_count(), |
|
274 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
277 | 275 | $is_update ? '%' : '' |
278 | 276 | ), |
279 | 277 | 'manage_give_settings', |
280 | 278 | 'give-updates', |
281 | - array( $this, 'render_page' ) |
|
279 | + array($this, 'render_page') |
|
282 | 280 | ); |
283 | 281 | } |
284 | 282 | |
@@ -293,13 +291,13 @@ discard block |
||
293 | 291 | // Show db upgrade completed notice. |
294 | 292 | if ( |
295 | 293 | ! wp_doing_ajax() && |
296 | - current_user_can( 'manage_give_settings' ) && |
|
297 | - get_option( 'give_show_db_upgrade_complete_notice' ) && |
|
298 | - ! isset( $_GET['give-db-update-completed'] ) |
|
294 | + current_user_can('manage_give_settings') && |
|
295 | + get_option('give_show_db_upgrade_complete_notice') && |
|
296 | + ! isset($_GET['give-db-update-completed']) |
|
299 | 297 | ) { |
300 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
298 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
301 | 299 | |
302 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-updates&give-db-update-completed=give_db_upgrade_completed' ) ); |
|
300 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-updates&give-db-update-completed=give_db_upgrade_completed')); |
|
303 | 301 | exit(); |
304 | 302 | } |
305 | 303 | } |
@@ -315,15 +313,15 @@ discard block |
||
315 | 313 | * |
316 | 314 | * @return bool |
317 | 315 | */ |
318 | - public function __pause_db_update( $force = false ) { |
|
316 | + public function __pause_db_update($force = false) { |
|
319 | 317 | // Bailout. |
320 | 318 | if ( |
321 | 319 | ! $force && |
322 | 320 | ( |
323 | 321 | wp_doing_ajax() || |
324 | - ! isset( $_GET['page'] ) || |
|
322 | + ! isset($_GET['page']) || |
|
325 | 323 | 'give-updates' !== $_GET['page'] || |
326 | - ! isset( $_GET['give-pause-db-upgrades'] ) || |
|
324 | + ! isset($_GET['give-pause-db-upgrades']) || |
|
327 | 325 | self::$background_updater->is_paused_process() |
328 | 326 | ) |
329 | 327 | |
@@ -331,13 +329,13 @@ discard block |
||
331 | 329 | return false; |
332 | 330 | } |
333 | 331 | |
334 | - delete_option( 'give_upgrade_error' ); |
|
332 | + delete_option('give_upgrade_error'); |
|
335 | 333 | |
336 | - $this->__health_background_update( $this ); |
|
334 | + $this->__health_background_update($this); |
|
337 | 335 | $batch = self::$background_updater->get_all_batch(); |
338 | 336 | |
339 | 337 | // Bailout: if batch is empty |
340 | - if ( empty( $batch->data ) ) { |
|
338 | + if (empty($batch->data)) { |
|
341 | 339 | return false; |
342 | 340 | } |
343 | 341 | |
@@ -346,25 +344,25 @@ discard block |
||
346 | 344 | |
347 | 345 | // Do not stop background process immediately if task running. |
348 | 346 | // @see Give_Background_Updater::lock_process |
349 | - if ( ! $force && self::$background_updater->is_process_running() ) { |
|
350 | - update_option( 'give_pause_upgrade', 1, false ); |
|
347 | + if ( ! $force && self::$background_updater->is_process_running()) { |
|
348 | + update_option('give_pause_upgrade', 1, false); |
|
351 | 349 | |
352 | 350 | return true; |
353 | 351 | } |
354 | 352 | |
355 | - update_option( 'give_paused_batches', $batch, false ); |
|
356 | - delete_option( $batch->key ); |
|
357 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
358 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
353 | + update_option('give_paused_batches', $batch, false); |
|
354 | + delete_option($batch->key); |
|
355 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
356 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
359 | 357 | |
360 | - Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' ); |
|
358 | + Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update'); |
|
361 | 359 | |
362 | 360 | /** |
363 | 361 | * Fire action when pause db updates |
364 | 362 | * |
365 | 363 | * @since 2.0.1 |
366 | 364 | */ |
367 | - do_action( 'give_pause_db_upgrade', $this ); |
|
365 | + do_action('give_pause_db_upgrade', $this); |
|
368 | 366 | |
369 | 367 | return true; |
370 | 368 | } |
@@ -381,31 +379,31 @@ discard block |
||
381 | 379 | // Bailout. |
382 | 380 | if ( |
383 | 381 | wp_doing_ajax() || |
384 | - ! isset( $_GET['page'] ) || |
|
382 | + ! isset($_GET['page']) || |
|
385 | 383 | 'give-updates' !== $_GET['page'] || |
386 | - ! isset( $_GET['give-restart-db-upgrades'] ) || |
|
384 | + ! isset($_GET['give-restart-db-upgrades']) || |
|
387 | 385 | ! self::$background_updater->is_paused_process() |
388 | 386 | ) { |
389 | 387 | return false; |
390 | 388 | } |
391 | 389 | |
392 | 390 | Give_Background_Updater::flush_cache(); |
393 | - $batch = get_option( 'give_paused_batches' ); |
|
391 | + $batch = get_option('give_paused_batches'); |
|
394 | 392 | |
395 | - if ( ! empty( $batch ) ) { |
|
396 | - wp_cache_delete( $batch->key, 'options' ); |
|
397 | - update_option( $batch->key, $batch->data, false ); |
|
393 | + if ( ! empty($batch)) { |
|
394 | + wp_cache_delete($batch->key, 'options'); |
|
395 | + update_option($batch->key, $batch->data, false); |
|
398 | 396 | |
399 | - delete_option( 'give_paused_batches' ); |
|
397 | + delete_option('give_paused_batches'); |
|
400 | 398 | |
401 | - Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' ); |
|
399 | + Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update'); |
|
402 | 400 | |
403 | 401 | |
404 | 402 | /** Fire action when restart db updates |
405 | 403 | * |
406 | 404 | * @since 2.0.1 |
407 | 405 | */ |
408 | - do_action( 'give_restart_db_upgrade', $this ); |
|
406 | + do_action('give_restart_db_upgrade', $this); |
|
409 | 407 | |
410 | 408 | self::$background_updater->dispatch(); |
411 | 409 | } |
@@ -421,53 +419,53 @@ discard block |
||
421 | 419 | * |
422 | 420 | * @param Give_Updates $give_updates |
423 | 421 | */ |
424 | - public function __health_background_update( $give_updates ) { |
|
425 | - if ( ! $this->is_doing_updates() ) { |
|
422 | + public function __health_background_update($give_updates) { |
|
423 | + if ( ! $this->is_doing_updates()) { |
|
426 | 424 | return; |
427 | 425 | } |
428 | 426 | |
429 | 427 | Give_Background_Updater::flush_cache(); |
430 | 428 | |
431 | 429 | $batch = Give_Updates::$background_updater->get_all_batch(); |
432 | - $batch_data_count = count( $batch->data ); |
|
433 | - $all_updates = $give_updates->get_updates( 'database', 'all' ); |
|
434 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
435 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
430 | + $batch_data_count = count($batch->data); |
|
431 | + $all_updates = $give_updates->get_updates('database', 'all'); |
|
432 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
433 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
436 | 434 | $log_data = ''; |
437 | - $doing_upgrade_args = get_option( 'give_doing_upgrade' ); |
|
435 | + $doing_upgrade_args = get_option('give_doing_upgrade'); |
|
438 | 436 | |
439 | - if ( ! empty( $doing_upgrade_args ) ) { |
|
440 | - $log_data .= 'Doing update:' . "\n"; |
|
441 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
437 | + if ( ! empty($doing_upgrade_args)) { |
|
438 | + $log_data .= 'Doing update:'."\n"; |
|
439 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
442 | 440 | } |
443 | 441 | |
444 | 442 | /** |
445 | 443 | * Add remove upgrade from batch |
446 | 444 | */ |
447 | - if ( ! empty( $batch->data ) ) { |
|
445 | + if ( ! empty($batch->data)) { |
|
448 | 446 | |
449 | - foreach ( $batch->data as $index => $update ) { |
|
450 | - $log_data = print_r( $update, true ) . "\n"; |
|
447 | + foreach ($batch->data as $index => $update) { |
|
448 | + $log_data = print_r($update, true)."\n"; |
|
451 | 449 | |
452 | - if ( ! is_callable( $update['callback'] ) ) { |
|
453 | - $log_data .= 'Removing missing callback update: ' . "{$update['id']}\n"; |
|
454 | - unset( $batch->data[ $index ] ); |
|
455 | - } elseif ( give_has_upgrade_completed( $update['id'] ) ) { |
|
456 | - $log_data .= 'Removing already completed update: ' . "{$update['id']}\n"; |
|
457 | - unset( $batch->data[ $index ] ); |
|
450 | + if ( ! is_callable($update['callback'])) { |
|
451 | + $log_data .= 'Removing missing callback update: '."{$update['id']}\n"; |
|
452 | + unset($batch->data[$index]); |
|
453 | + } elseif (give_has_upgrade_completed($update['id'])) { |
|
454 | + $log_data .= 'Removing already completed update: '."{$update['id']}\n"; |
|
455 | + unset($batch->data[$index]); |
|
458 | 456 | } |
459 | 457 | |
460 | - if ( ! empty( $update['depend'] ) ) { |
|
458 | + if ( ! empty($update['depend'])) { |
|
461 | 459 | |
462 | - foreach ( $update['depend'] as $depend ) { |
|
463 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
464 | - $log_data .= 'Completed update: ' . "{$depend}\n"; |
|
460 | + foreach ($update['depend'] as $depend) { |
|
461 | + if (give_has_upgrade_completed($depend)) { |
|
462 | + $log_data .= 'Completed update: '."{$depend}\n"; |
|
465 | 463 | continue; |
466 | 464 | } |
467 | 465 | |
468 | - if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) { |
|
469 | - $log_data .= 'Adding missing update: ' . "{$depend}\n"; |
|
470 | - array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] ); |
|
466 | + if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) { |
|
467 | + $log_data .= 'Adding missing update: '."{$depend}\n"; |
|
468 | + array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]); |
|
471 | 469 | } |
472 | 470 | } |
473 | 471 | } |
@@ -477,52 +475,52 @@ discard block |
||
477 | 475 | /** |
478 | 476 | * Add new upgrade to batch |
479 | 477 | */ |
480 | - if ( $new_updates = $this->get_updates( 'database', 'new' ) ) { |
|
481 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
478 | + if ($new_updates = $this->get_updates('database', 'new')) { |
|
479 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
482 | 480 | |
483 | - foreach ( $new_updates as $index => $new_update ) { |
|
484 | - if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) { |
|
485 | - unset( $new_updates[ $index ] ); |
|
481 | + foreach ($new_updates as $index => $new_update) { |
|
482 | + if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) { |
|
483 | + unset($new_updates[$index]); |
|
486 | 484 | } |
487 | 485 | } |
488 | 486 | |
489 | - if ( ! empty( $new_updates ) ) { |
|
490 | - $log_data .= 'Adding new update: ' . "\n"; |
|
491 | - $log_data .= print_r( $new_updates, true ) . "\n"; |
|
487 | + if ( ! empty($new_updates)) { |
|
488 | + $log_data .= 'Adding new update: '."\n"; |
|
489 | + $log_data .= print_r($new_updates, true)."\n"; |
|
492 | 490 | |
493 | - $batch->data = array_merge( (array) $batch->data, $new_updates ); |
|
494 | - update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ), false ); |
|
491 | + $batch->data = array_merge((array) $batch->data, $new_updates); |
|
492 | + update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates)), false); |
|
495 | 493 | } |
496 | 494 | } |
497 | 495 | |
498 | 496 | /** |
499 | 497 | * Fix batch |
500 | 498 | */ |
501 | - if ( empty( $batch->data ) ) { |
|
499 | + if (empty($batch->data)) { |
|
502 | 500 | // Complete batch if do not have any data to process. |
503 | - self::$background_updater->delete( $batch->key ); |
|
501 | + self::$background_updater->delete($batch->key); |
|
504 | 502 | |
505 | - if ( self::$background_updater->has_queue() ) { |
|
506 | - $this->__health_background_update( $this ); |
|
503 | + if (self::$background_updater->has_queue()) { |
|
504 | + $this->__health_background_update($this); |
|
507 | 505 | } else { |
508 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
509 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
506 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
507 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
510 | 508 | |
511 | 509 | self::$background_updater->complete(); |
512 | 510 | } |
513 | 511 | |
514 | - } elseif ( $batch_data_count !== count( $batch->data ) ) { |
|
512 | + } elseif ($batch_data_count !== count($batch->data)) { |
|
515 | 513 | |
516 | - $log_data .= 'Updating batch' . "\n"; |
|
517 | - $log_data .= print_r( $batch, true ); |
|
514 | + $log_data .= 'Updating batch'."\n"; |
|
515 | + $log_data .= print_r($batch, true); |
|
518 | 516 | |
519 | - if ( ! empty( $batch->key ) ) { |
|
520 | - wp_cache_delete( $batch->key, 'options' ); |
|
521 | - update_option( $batch->key, $batch->data, false ); |
|
517 | + if ( ! empty($batch->key)) { |
|
518 | + wp_cache_delete($batch->key, 'options'); |
|
519 | + update_option($batch->key, $batch->data, false); |
|
522 | 520 | } else { |
523 | 521 | |
524 | - foreach ( $batch->data as $data ) { |
|
525 | - Give_Updates::$background_updater->push_to_queue( $data ); |
|
522 | + foreach ($batch->data as $data) { |
|
523 | + Give_Updates::$background_updater->push_to_queue($data); |
|
526 | 524 | } |
527 | 525 | |
528 | 526 | Give_Updates::$background_updater->save(); |
@@ -533,31 +531,31 @@ discard block |
||
533 | 531 | /** |
534 | 532 | * Fix give_doing_upgrade option |
535 | 533 | */ |
536 | - if( $fresh_new_db_count = $this->get_total_new_db_update_count( true ) ) { |
|
537 | - update_option( 'give_db_update_count', $fresh_new_db_count, false ); |
|
534 | + if ($fresh_new_db_count = $this->get_total_new_db_update_count(true)) { |
|
535 | + update_option('give_db_update_count', $fresh_new_db_count, false); |
|
538 | 536 | } |
539 | 537 | |
540 | 538 | $doing_upgrade_args['update'] = 1; |
541 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count ); |
|
542 | - $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true ); |
|
539 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, $fresh_new_db_count); |
|
540 | + $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(true); |
|
543 | 541 | |
544 | 542 | // Remove already completed update from info. |
545 | 543 | if ( |
546 | - empty( $doing_upgrade_args['update_info'] ) |
|
547 | - || give_has_upgrade_completed( $doing_upgrade_args['update_info']['id'] ) |
|
544 | + empty($doing_upgrade_args['update_info']) |
|
545 | + || give_has_upgrade_completed($doing_upgrade_args['update_info']['id']) |
|
548 | 546 | ) { |
549 | - $doing_upgrade_args['update_info'] = current( array_values( $batch->data ) ); |
|
547 | + $doing_upgrade_args['update_info'] = current(array_values($batch->data)); |
|
550 | 548 | $doing_upgrade_args['step'] = 1; |
551 | 549 | } |
552 | 550 | |
553 | 551 | // Check if dependency completed or not. |
554 | - if ( isset( $doing_upgrade_args['update_info']['depend'] ) ) { |
|
555 | - foreach ( $doing_upgrade_args['update_info']['depend'] as $depend ) { |
|
556 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
552 | + if (isset($doing_upgrade_args['update_info']['depend'])) { |
|
553 | + foreach ($doing_upgrade_args['update_info']['depend'] as $depend) { |
|
554 | + if (give_has_upgrade_completed($depend)) { |
|
557 | 555 | continue; |
558 | 556 | } |
559 | 557 | |
560 | - $doing_upgrade_args['update_info'] = $all_updates[ array_search( $depend, $all_update_ids ) ]; |
|
558 | + $doing_upgrade_args['update_info'] = $all_updates[array_search($depend, $all_update_ids)]; |
|
561 | 559 | $doing_upgrade_args['step'] = 1; |
562 | 560 | $doing_upgrade_args['percentage'] = 0; |
563 | 561 | $doing_upgrade_args['total_percentage'] = 0; |
@@ -566,14 +564,14 @@ discard block |
||
566 | 564 | } |
567 | 565 | } |
568 | 566 | |
569 | - if( ! empty( $doing_upgrade_args['update_info'] ) ) { |
|
570 | - update_option( 'give_doing_upgrade', $doing_upgrade_args, false ); |
|
567 | + if ( ! empty($doing_upgrade_args['update_info'])) { |
|
568 | + update_option('give_doing_upgrade', $doing_upgrade_args, false); |
|
571 | 569 | |
572 | - $log_data .= 'Updated doing update:' . "\n"; |
|
573 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
570 | + $log_data .= 'Updated doing update:'."\n"; |
|
571 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
574 | 572 | } |
575 | 573 | |
576 | - Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' ); |
|
574 | + Give()->logs->add('Update Health Check', $log_data, 0, 'update'); |
|
577 | 575 | } |
578 | 576 | |
579 | 577 | |
@@ -587,90 +585,90 @@ discard block |
||
587 | 585 | $current_screen = get_current_screen(); |
588 | 586 | |
589 | 587 | // Bailout. |
590 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
588 | + if ( ! current_user_can('manage_give_settings')) { |
|
591 | 589 | return; |
592 | 590 | } |
593 | 591 | |
594 | 592 | // Run DB updates. |
595 | - if ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
593 | + if ( ! empty($_GET['give-run-db-update'])) { |
|
596 | 594 | $this->run_db_update(); |
597 | 595 | } |
598 | 596 | |
599 | 597 | |
600 | 598 | // Bailout. |
601 | - if ( in_array( $current_screen->base, array( 'give_forms_page_give-updates', 'update-core' ) ) ) { |
|
599 | + if (in_array($current_screen->base, array('give_forms_page_give-updates', 'update-core'))) { |
|
602 | 600 | return; |
603 | 601 | } |
604 | 602 | |
605 | 603 | // Show notice if upgrade paused. |
606 | - if ( self::$background_updater->is_paused_process() ) { |
|
604 | + if (self::$background_updater->is_paused_process()) { |
|
607 | 605 | ob_start(); |
608 | 606 | |
609 | - $upgrade_error = get_option( 'give_upgrade_error' ); |
|
610 | - if ( ! $upgrade_error ) : ?> |
|
611 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
612 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?> |
|
607 | + $upgrade_error = get_option('give_upgrade_error'); |
|
608 | + if ( ! $upgrade_error) : ?> |
|
609 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
610 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?> |
|
613 | 611 | <br> |
614 | 612 | <br> |
615 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn"> |
|
616 | - <?php _e( 'Restart the updater', 'give' ); ?> |
|
613 | + <a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn"> |
|
614 | + <?php _e('Restart the updater', 'give'); ?> |
|
617 | 615 | </a> |
618 | 616 | <?php else: ?> |
619 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
620 | - – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
621 | - <a href="<?php echo esc_url('http://docs.givewp.com/troubleshooting-db-updates')?>" target="_blank"><?php _e( 'Read More', 'give' ); ?> »</a> |
|
617 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
618 | + – <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
619 | + <a href="<?php echo esc_url('http://docs.givewp.com/troubleshooting-db-updates')?>" target="_blank"><?php _e('Read More', 'give'); ?> »</a> |
|
622 | 620 | <?php |
623 | 621 | endif; |
624 | 622 | $desc_html = ob_get_clean(); |
625 | 623 | |
626 | - Give()->notices->register_notice( array( |
|
624 | + Give()->notices->register_notice(array( |
|
627 | 625 | 'id' => 'give_upgrade_db', |
628 | 626 | 'type' => 'error', |
629 | 627 | 'dismissible' => false, |
630 | 628 | 'description' => $desc_html, |
631 | - ) ); |
|
629 | + )); |
|
632 | 630 | } |
633 | 631 | |
634 | 632 | // Bailout if doing upgrades. |
635 | - if ( $this->is_doing_updates() ) { |
|
633 | + if ($this->is_doing_updates()) { |
|
636 | 634 | return; |
637 | 635 | } |
638 | 636 | |
639 | 637 | // Show db upgrade completed notice. |
640 | - if ( ! empty( $_GET['give-db-update-completed'] ) ) { |
|
641 | - Give()->notices->register_notice( array( |
|
638 | + if ( ! empty($_GET['give-db-update-completed'])) { |
|
639 | + Give()->notices->register_notice(array( |
|
642 | 640 | 'id' => 'give_db_upgrade_completed', |
643 | 641 | 'type' => 'updated', |
644 | - 'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
642 | + 'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
645 | 643 | 'show' => true, |
646 | - ) ); |
|
644 | + )); |
|
647 | 645 | |
648 | 646 | // Start update. |
649 | - } elseif ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
647 | + } elseif ( ! empty($_GET['give-run-db-update'])) { |
|
650 | 648 | $this->run_db_update(); |
651 | 649 | |
652 | 650 | // Show run the update notice. |
653 | - } elseif ( $this->get_total_new_db_update_count() ) { |
|
651 | + } elseif ($this->get_total_new_db_update_count()) { |
|
654 | 652 | ob_start(); |
655 | 653 | ?> |
656 | 654 | <p> |
657 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
658 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?> |
|
655 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
656 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?> |
|
659 | 657 | </p> |
660 | 658 | <p class="submit"> |
661 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now"> |
|
662 | - <?php _e( 'Run the updater', 'give' ); ?> |
|
659 | + <a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now"> |
|
660 | + <?php _e('Run the updater', 'give'); ?> |
|
663 | 661 | </a> |
664 | 662 | </p> |
665 | 663 | <?php |
666 | 664 | $desc_html = ob_get_clean(); |
667 | 665 | |
668 | - Give()->notices->register_notice( array( |
|
666 | + Give()->notices->register_notice(array( |
|
669 | 667 | 'id' => 'give_upgrade_db', |
670 | 668 | 'type' => 'updated', |
671 | 669 | 'dismissible' => false, |
672 | 670 | 'description' => $desc_html, |
673 | - ) ); |
|
671 | + )); |
|
674 | 672 | } |
675 | 673 | } |
676 | 674 | |
@@ -681,7 +679,7 @@ discard block |
||
681 | 679 | * @access public |
682 | 680 | */ |
683 | 681 | public function render_complete_page() { |
684 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
682 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
685 | 683 | } |
686 | 684 | |
687 | 685 | /** |
@@ -691,7 +689,7 @@ discard block |
||
691 | 689 | * @access public |
692 | 690 | */ |
693 | 691 | public function render_page() { |
694 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
692 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
695 | 693 | } |
696 | 694 | |
697 | 695 | /** |
@@ -702,26 +700,26 @@ discard block |
||
702 | 700 | */ |
703 | 701 | private function run_db_update() { |
704 | 702 | // Bailout. |
705 | - if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) { |
|
703 | + if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) { |
|
706 | 704 | return; |
707 | 705 | } |
708 | 706 | |
709 | - $updates = $this->get_updates( 'database', 'new' ); |
|
707 | + $updates = $this->get_updates('database', 'new'); |
|
710 | 708 | |
711 | - foreach ( $updates as $update ) { |
|
712 | - self::$background_updater->push_to_queue( $update ); |
|
709 | + foreach ($updates as $update) { |
|
710 | + self::$background_updater->push_to_queue($update); |
|
713 | 711 | } |
714 | 712 | |
715 | - add_option( 'give_db_update_count', count( $updates ), '', false ); |
|
713 | + add_option('give_db_update_count', count($updates), '', false); |
|
716 | 714 | |
717 | - add_option( 'give_doing_upgrade', array( |
|
715 | + add_option('give_doing_upgrade', array( |
|
718 | 716 | 'update_info' => $updates[0], |
719 | 717 | 'step' => 1, |
720 | 718 | 'update' => 1, |
721 | - 'heading' => sprintf( 'Update %s of %s', 1, count( $updates ) ), |
|
719 | + 'heading' => sprintf('Update %s of %s', 1, count($updates)), |
|
722 | 720 | 'percentage' => 0, |
723 | 721 | 'total_percentage' => 0, |
724 | - ), '', false ); |
|
722 | + ), '', false); |
|
725 | 723 | |
726 | 724 | self::$background_updater->save()->dispatch(); |
727 | 725 | } |
@@ -735,14 +733,13 @@ discard block |
||
735 | 733 | */ |
736 | 734 | public function __flush_resume_updates() { |
737 | 735 | //delete_option( 'give_doing_upgrade' ); |
738 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
736 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
739 | 737 | |
740 | 738 | // Reset counter. |
741 | 739 | $this->step = $this->percentage = 0; |
742 | 740 | |
743 | - $this->update = ( $this->get_total_db_update_count() > $this->update ) ? |
|
744 | - ( $this->update + 1 ) : |
|
745 | - $this->update; |
|
741 | + $this->update = ($this->get_total_db_update_count() > $this->update) ? |
|
742 | + ($this->update + 1) : $this->update; |
|
746 | 743 | } |
747 | 744 | |
748 | 745 | |
@@ -757,7 +754,7 @@ discard block |
||
757 | 754 | public function __give_start_updating() { |
758 | 755 | // Check permission. |
759 | 756 | if ( |
760 | - ! current_user_can( 'manage_give_settings' ) || |
|
757 | + ! current_user_can('manage_give_settings') || |
|
761 | 758 | $this->is_doing_updates() |
762 | 759 | ) { |
763 | 760 | // Run update via ajax |
@@ -768,7 +765,7 @@ discard block |
||
768 | 765 | |
769 | 766 | // @todo: validate nonce |
770 | 767 | // @todo: set http method to post |
771 | - if ( empty( $_POST['run_db_update'] ) ) { |
|
768 | + if (empty($_POST['run_db_update'])) { |
|
772 | 769 | wp_send_json_error(); |
773 | 770 | } |
774 | 771 | |
@@ -787,34 +784,34 @@ discard block |
||
787 | 784 | * @return string |
788 | 785 | */ |
789 | 786 | public function __give_db_updates_info() { |
790 | - $update_info = get_option( 'give_doing_upgrade' ); |
|
787 | + $update_info = get_option('give_doing_upgrade'); |
|
791 | 788 | $response_type = ''; |
792 | 789 | |
793 | - if ( self::$background_updater->is_paused_process() ) { |
|
790 | + if (self::$background_updater->is_paused_process()) { |
|
794 | 791 | $update_info = array( |
795 | - 'message' => __( 'The updates have been paused.', 'give' ), |
|
792 | + 'message' => __('The updates have been paused.', 'give'), |
|
796 | 793 | 'heading' => '', |
797 | 794 | 'percentage' => 0, |
798 | 795 | ); |
799 | 796 | |
800 | - if ( get_option( 'give_upgrade_error' ) ) { |
|
801 | - $update_info['message'] = __( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); |
|
797 | + if (get_option('give_upgrade_error')) { |
|
798 | + $update_info['message'] = __('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); |
|
802 | 799 | } |
803 | 800 | |
804 | 801 | $response_type = 'error'; |
805 | 802 | |
806 | - } elseif ( empty( $update_info ) || ! $this->get_total_new_db_update_count( true ) ) { |
|
803 | + } elseif (empty($update_info) || ! $this->get_total_new_db_update_count(true)) { |
|
807 | 804 | $update_info = array( |
808 | - 'message' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
809 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
805 | + 'message' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
806 | + 'heading' => __('Updates Completed.', 'give'), |
|
810 | 807 | 'percentage' => 0, |
811 | 808 | ); |
812 | 809 | $response_type = 'success'; |
813 | 810 | |
814 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
811 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
815 | 812 | } |
816 | 813 | |
817 | - $this->send_ajax_response( $update_info, $response_type ); |
|
814 | + $this->send_ajax_response($update_info, $response_type); |
|
818 | 815 | } |
819 | 816 | |
820 | 817 | /** |
@@ -826,7 +823,7 @@ discard block |
||
826 | 823 | * @param $data |
827 | 824 | * @param string $type |
828 | 825 | */ |
829 | - public function send_ajax_response( $data, $type = '' ) { |
|
826 | + public function send_ajax_response($data, $type = '') { |
|
830 | 827 | $default = array( |
831 | 828 | 'message' => '', |
832 | 829 | 'heading' => '', |
@@ -836,24 +833,24 @@ discard block |
||
836 | 833 | ); |
837 | 834 | |
838 | 835 | // Set data. |
839 | - $data = wp_parse_args( $data, $default ); |
|
836 | + $data = wp_parse_args($data, $default); |
|
840 | 837 | |
841 | 838 | // Enable cache. |
842 | 839 | Give_Cache::enable(); |
843 | 840 | |
844 | - switch ( $type ) { |
|
841 | + switch ($type) { |
|
845 | 842 | case 'success': |
846 | - wp_send_json_success( $data ); |
|
843 | + wp_send_json_success($data); |
|
847 | 844 | break; |
848 | 845 | |
849 | 846 | case 'error': |
850 | - wp_send_json_error( $data ); |
|
847 | + wp_send_json_error($data); |
|
851 | 848 | break; |
852 | 849 | |
853 | 850 | default: |
854 | - wp_send_json( array( |
|
851 | + wp_send_json(array( |
|
855 | 852 | 'data' => $data, |
856 | - ) ); |
|
853 | + )); |
|
857 | 854 | break; |
858 | 855 | } |
859 | 856 | } |
@@ -867,12 +864,12 @@ discard block |
||
867 | 864 | * @param $total |
868 | 865 | * @param $current_total |
869 | 866 | */ |
870 | - public function set_percentage( $total, $current_total ) { |
|
867 | + public function set_percentage($total, $current_total) { |
|
871 | 868 | // Set percentage. |
872 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
869 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
873 | 870 | |
874 | 871 | // Verify percentage. |
875 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
872 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
876 | 873 | } |
877 | 874 | |
878 | 875 | /** |
@@ -885,22 +882,22 @@ discard block |
||
885 | 882 | * |
886 | 883 | * @return bool|null |
887 | 884 | */ |
888 | - public function is_parent_updates_completed( $update ) { |
|
885 | + public function is_parent_updates_completed($update) { |
|
889 | 886 | // Bailout. |
890 | - if ( empty( $update['depend'] ) ) { |
|
887 | + if (empty($update['depend'])) { |
|
891 | 888 | return true; |
892 | 889 | } |
893 | 890 | |
894 | 891 | // Check if dependency is valid or not. |
895 | - if ( ! $this->has_valid_dependency( $update ) ) { |
|
892 | + if ( ! $this->has_valid_dependency($update)) { |
|
896 | 893 | return null; |
897 | 894 | } |
898 | 895 | |
899 | 896 | $is_dependency_completed = true; |
900 | 897 | |
901 | - foreach ( $update['depend'] as $depend ) { |
|
898 | + foreach ($update['depend'] as $depend) { |
|
902 | 899 | |
903 | - if ( ! give_has_upgrade_completed( $depend ) ) { |
|
900 | + if ( ! give_has_upgrade_completed($depend)) { |
|
904 | 901 | $is_dependency_completed = false; |
905 | 902 | break; |
906 | 903 | } |
@@ -917,7 +914,7 @@ discard block |
||
917 | 914 | * @return bool |
918 | 915 | */ |
919 | 916 | public function is_doing_updates() { |
920 | - return (bool) get_option( 'give_doing_upgrade' ); |
|
917 | + return (bool) get_option('give_doing_upgrade'); |
|
921 | 918 | } |
922 | 919 | |
923 | 920 | |
@@ -931,7 +928,7 @@ discard block |
||
931 | 928 | * |
932 | 929 | * @return bool |
933 | 930 | */ |
934 | - public function has_valid_dependency( $update ) { |
|
931 | + public function has_valid_dependency($update) { |
|
935 | 932 | $is_valid_dependency = true; |
936 | 933 | // $update_ids = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' ); |
937 | 934 | // |
@@ -957,33 +954,33 @@ discard block |
||
957 | 954 | * |
958 | 955 | * @return array |
959 | 956 | */ |
960 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
957 | + public function get_updates($update_type = '', $status = 'all') { |
|
961 | 958 | // return all updates. |
962 | - if ( empty( $update_type ) ) { |
|
959 | + if (empty($update_type)) { |
|
963 | 960 | return $this->updates; |
964 | 961 | } |
965 | 962 | |
966 | 963 | // Get specific update. |
967 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
964 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
968 | 965 | |
969 | 966 | // Bailout. |
970 | - if ( empty( $updates ) ) { |
|
967 | + if (empty($updates)) { |
|
971 | 968 | return $updates; |
972 | 969 | } |
973 | 970 | |
974 | - switch ( $status ) { |
|
971 | + switch ($status) { |
|
975 | 972 | case 'new': |
976 | 973 | // Remove already completed updates. |
977 | - wp_cache_delete( 'give_completed_upgrades', 'options' ); |
|
974 | + wp_cache_delete('give_completed_upgrades', 'options'); |
|
978 | 975 | $completed_updates = give_get_completed_upgrades(); |
979 | 976 | |
980 | - if ( ! empty( $completed_updates ) ) { |
|
981 | - foreach ( $updates as $index => $update ) { |
|
982 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
983 | - unset( $updates[ $index ] ); |
|
977 | + if ( ! empty($completed_updates)) { |
|
978 | + foreach ($updates as $index => $update) { |
|
979 | + if (in_array($update['id'], $completed_updates)) { |
|
980 | + unset($updates[$index]); |
|
984 | 981 | } |
985 | 982 | } |
986 | - $updates = array_values( $updates ); |
|
983 | + $updates = array_values($updates); |
|
987 | 984 | } |
988 | 985 | |
989 | 986 | break; |
@@ -1000,7 +997,7 @@ discard block |
||
1000 | 997 | * @return int |
1001 | 998 | */ |
1002 | 999 | public function get_total_plugin_update_count() { |
1003 | - return count( $this->get_updates( 'plugin' ) ); |
|
1000 | + return count($this->get_updates('plugin')); |
|
1004 | 1001 | } |
1005 | 1002 | |
1006 | 1003 | /** |
@@ -1015,7 +1012,7 @@ discard block |
||
1015 | 1012 | $db_update_count = $this->get_pending_db_update_count(); |
1016 | 1013 | $plugin_update_count = $this->get_total_plugin_update_count(); |
1017 | 1014 | |
1018 | - return ( $db_update_count + $plugin_update_count ); |
|
1015 | + return ($db_update_count + $plugin_update_count); |
|
1019 | 1016 | } |
1020 | 1017 | |
1021 | 1018 | /** |
@@ -1027,7 +1024,7 @@ discard block |
||
1027 | 1024 | * @return int |
1028 | 1025 | */ |
1029 | 1026 | public function get_pending_db_update_count() { |
1030 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
1027 | + return count($this->get_updates('database', 'new')); |
|
1031 | 1028 | } |
1032 | 1029 | |
1033 | 1030 | /** |
@@ -1039,7 +1036,7 @@ discard block |
||
1039 | 1036 | * @return int |
1040 | 1037 | */ |
1041 | 1038 | public function get_total_db_update_count() { |
1042 | - return count( $this->get_updates( 'database', 'all' ) ); |
|
1039 | + return count($this->get_updates('database', 'all')); |
|
1043 | 1040 | } |
1044 | 1041 | |
1045 | 1042 | /** |
@@ -1052,10 +1049,9 @@ discard block |
||
1052 | 1049 | * |
1053 | 1050 | * @return int |
1054 | 1051 | */ |
1055 | - public function get_total_new_db_update_count( $refresh = false ) { |
|
1052 | + public function get_total_new_db_update_count($refresh = false) { |
|
1056 | 1053 | $update_count = $this->is_doing_updates() && ! $refresh ? |
1057 | - get_option( 'give_db_update_count' ) : |
|
1058 | - $this->get_pending_db_update_count(); |
|
1054 | + get_option('give_db_update_count') : $this->get_pending_db_update_count(); |
|
1059 | 1055 | |
1060 | 1056 | return $update_count; |
1061 | 1057 | } |
@@ -1070,11 +1066,11 @@ discard block |
||
1070 | 1066 | * |
1071 | 1067 | * @return int |
1072 | 1068 | */ |
1073 | - public function get_running_db_update( $refresh = false ) { |
|
1069 | + public function get_running_db_update($refresh = false) { |
|
1074 | 1070 | $current_update = 1; |
1075 | 1071 | |
1076 | - if ( $this->is_doing_updates() && ! $refresh ) { |
|
1077 | - $current_update = get_option( 'give_doing_upgrade' ); |
|
1072 | + if ($this->is_doing_updates() && ! $refresh) { |
|
1073 | + $current_update = get_option('give_doing_upgrade'); |
|
1078 | 1074 | $current_update = $current_update['update']; |
1079 | 1075 | } |
1080 | 1076 | |
@@ -1091,25 +1087,23 @@ discard block |
||
1091 | 1087 | * |
1092 | 1088 | * @return float|int |
1093 | 1089 | */ |
1094 | - public function get_db_update_processing_percentage( $refresh = false ) { |
|
1090 | + public function get_db_update_processing_percentage($refresh = false) { |
|
1095 | 1091 | // Bailout. |
1096 | - if ( ! $this->get_total_new_db_update_count( $refresh ) ) { |
|
1092 | + if ( ! $this->get_total_new_db_update_count($refresh)) { |
|
1097 | 1093 | return 0; |
1098 | 1094 | } |
1099 | 1095 | |
1100 | - $resume_update = get_option( 'give_doing_upgrade' ); |
|
1101 | - $update_count_percentages = ( ( $this->get_running_db_update( $refresh ) - 1 ) / $this->get_total_new_db_update_count( $refresh ) ) * 100; |
|
1102 | - $update_percentage_share = ( 1 / $this->get_total_new_db_update_count() ) * 100; |
|
1103 | - $upgrade_percentage = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 ); |
|
1096 | + $resume_update = get_option('give_doing_upgrade'); |
|
1097 | + $update_count_percentages = (($this->get_running_db_update($refresh) - 1) / $this->get_total_new_db_update_count($refresh)) * 100; |
|
1098 | + $update_percentage_share = (1 / $this->get_total_new_db_update_count()) * 100; |
|
1099 | + $upgrade_percentage = (($resume_update['percentage'] * $update_percentage_share) / 100); |
|
1104 | 1100 | |
1105 | 1101 | $final_percentage = $update_count_percentages + $upgrade_percentage; |
1106 | 1102 | |
1107 | 1103 | return $this->is_doing_updates() ? |
1108 | - ( absint( $final_percentage ) ? |
|
1109 | - absint( $final_percentage ) : |
|
1110 | - round( $final_percentage, 2 ) |
|
1111 | - ) : |
|
1112 | - 0; |
|
1104 | + (absint($final_percentage) ? |
|
1105 | + absint($final_percentage) : round($final_percentage, 2) |
|
1106 | + ) : 0; |
|
1113 | 1107 | } |
1114 | 1108 | |
1115 | 1109 | |
@@ -1121,8 +1115,8 @@ discard block |
||
1121 | 1115 | * @return array |
1122 | 1116 | */ |
1123 | 1117 | public function get_update_ids() { |
1124 | - $all_updates = $this->get_updates( 'database', 'all' ); |
|
1125 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
1118 | + $all_updates = $this->get_updates('database', 'all'); |
|
1119 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
1126 | 1120 | |
1127 | 1121 | return $all_update_ids; |
1128 | 1122 | } |
@@ -1137,10 +1131,9 @@ discard block |
||
1137 | 1131 | * |
1138 | 1132 | * @return float|int |
1139 | 1133 | */ |
1140 | - public function get_offset( $process_item_count ) { |
|
1141 | - return ( 1 === $this->step ) ? |
|
1142 | - 0 : |
|
1143 | - ( $this->step - 1 ) * $process_item_count; |
|
1134 | + public function get_offset($process_item_count) { |
|
1135 | + return (1 === $this->step) ? |
|
1136 | + 0 : ($this->step - 1) * $process_item_count; |
|
1144 | 1137 | } |
1145 | 1138 | } |
1146 | 1139 |
@@ -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 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct() { |
26 | 26 | |
27 | - $this->shortcode['title'] = esc_html__( 'Donation Receipt', 'give' ); |
|
28 | - $this->shortcode['label'] = esc_html__( 'Donation Receipt', 'give' ); |
|
27 | + $this->shortcode['title'] = esc_html__('Donation Receipt', 'give'); |
|
28 | + $this->shortcode['label'] = esc_html__('Donation Receipt', 'give'); |
|
29 | 29 | |
30 | - parent::__construct( 'give_receipt' ); |
|
30 | + parent::__construct('give_receipt'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -40,71 +40,71 @@ discard block |
||
40 | 40 | return array( |
41 | 41 | array( |
42 | 42 | 'type' => 'container', |
43 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
43 | + 'html' => sprintf('<p class="strong">%s</p>', esc_html__('Optional settings', 'give')), |
|
44 | 44 | ), |
45 | 45 | array( |
46 | 46 | 'type' => 'listbox', |
47 | 47 | 'name' => 'price', |
48 | - 'label' => esc_html__( 'Show Donation Amount:', 'give' ), |
|
48 | + 'label' => esc_html__('Show Donation Amount:', 'give'), |
|
49 | 49 | 'options' => array( |
50 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
50 | + 'false' => esc_html__('Hide', 'give'), |
|
51 | 51 | ), |
52 | - 'placeholder' => esc_html__( 'Show', 'give' ) |
|
52 | + 'placeholder' => esc_html__('Show', 'give') |
|
53 | 53 | ), |
54 | 54 | array( |
55 | 55 | 'type' => 'listbox', |
56 | 56 | 'name' => 'donor', |
57 | - 'label' => esc_html__( 'Show Donor Name:', 'give' ), |
|
57 | + 'label' => esc_html__('Show Donor Name:', 'give'), |
|
58 | 58 | 'options' => array( |
59 | - 'true' => esc_html__( 'Show', 'give' ), |
|
60 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
59 | + 'true' => esc_html__('Show', 'give'), |
|
60 | + 'false' => esc_html__('Hide', 'give'), |
|
61 | 61 | ), |
62 | - 'placeholder' => esc_html__( 'Show', 'give' ) |
|
62 | + 'placeholder' => esc_html__('Show', 'give') |
|
63 | 63 | ), |
64 | 64 | array( |
65 | 65 | 'type' => 'listbox', |
66 | 66 | 'name' => 'date', |
67 | - 'label' => esc_html__( 'Show Date:', 'give' ), |
|
67 | + 'label' => esc_html__('Show Date:', 'give'), |
|
68 | 68 | 'options' => array( |
69 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
69 | + 'false' => esc_html__('Hide', 'give'), |
|
70 | 70 | ), |
71 | - 'placeholder' => esc_html__( 'Show', 'give' ), |
|
71 | + 'placeholder' => esc_html__('Show', 'give'), |
|
72 | 72 | ), |
73 | 73 | array( |
74 | 74 | 'type' => 'listbox', |
75 | 75 | 'name' => 'payment_key', |
76 | - 'label' => esc_html__( 'Show Payment Key:', 'give' ), |
|
76 | + 'label' => esc_html__('Show Payment Key:', 'give'), |
|
77 | 77 | 'options' => array( |
78 | - 'true' => esc_html__( 'Show', 'give' ), |
|
78 | + 'true' => esc_html__('Show', 'give'), |
|
79 | 79 | ), |
80 | - 'placeholder' => esc_html__( 'Hide', 'give' ), |
|
80 | + 'placeholder' => esc_html__('Hide', 'give'), |
|
81 | 81 | ), |
82 | 82 | array( |
83 | 83 | 'type' => 'listbox', |
84 | 84 | 'name' => 'payment_method', |
85 | - 'label' => esc_html__( 'Show Payment Method:', 'give' ), |
|
85 | + 'label' => esc_html__('Show Payment Method:', 'give'), |
|
86 | 86 | 'options' => array( |
87 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
87 | + 'false' => esc_html__('Hide', 'give'), |
|
88 | 88 | ), |
89 | - 'placeholder' => esc_html__( 'Show', 'give' ), |
|
89 | + 'placeholder' => esc_html__('Show', 'give'), |
|
90 | 90 | ), |
91 | 91 | array( |
92 | 92 | 'type' => 'listbox', |
93 | 93 | 'name' => 'payment_id', |
94 | - 'label' => esc_html__( 'Show Payment ID:', 'give' ), |
|
94 | + 'label' => esc_html__('Show Payment ID:', 'give'), |
|
95 | 95 | 'options' => array( |
96 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
96 | + 'false' => esc_html__('Hide', 'give'), |
|
97 | 97 | ), |
98 | - 'placeholder' => esc_html__( 'Show', 'give' ), |
|
98 | + 'placeholder' => esc_html__('Show', 'give'), |
|
99 | 99 | ), |
100 | 100 | array( |
101 | 101 | 'type' => 'listbox', |
102 | 102 | 'name' => 'company_name', |
103 | - 'label' => esc_html__( 'Company Name:', 'give' ), |
|
103 | + 'label' => esc_html__('Company Name:', 'give'), |
|
104 | 104 | 'options' => array( |
105 | - 'true' => esc_html__( 'Show', 'give' ), |
|
105 | + 'true' => esc_html__('Show', 'give'), |
|
106 | 106 | ), |
107 | - 'placeholder' => esc_html__( 'Hide', 'give' ) |
|
107 | + 'placeholder' => esc_html__('Hide', 'give') |
|
108 | 108 | ), |
109 | 109 | ); |
110 | 110 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if access directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return static |
47 | 47 | */ |
48 | 48 | static function get_instance() { |
49 | - if ( null === static::$instance ) { |
|
49 | + if (null === static::$instance) { |
|
50 | 50 | self::$instance = new static(); |
51 | 51 | } |
52 | 52 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - public static function has_preview( Give_Email_Notification $email ) { |
|
67 | + public static function has_preview(Give_Email_Notification $email) { |
|
68 | 68 | return $email->config['has_preview']; |
69 | 69 | } |
70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public static function has_recipient_field( Give_Email_Notification $email ) { |
|
81 | + public static function has_recipient_field(Give_Email_Notification $email) { |
|
82 | 82 | return $email->config['has_recipient_field']; |
83 | 83 | } |
84 | 84 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return bool |
94 | 94 | */ |
95 | - public static function is_notification_status_editable( Give_Email_Notification $email ) { |
|
95 | + public static function is_notification_status_editable(Give_Email_Notification $email) { |
|
96 | 96 | $user_can_edit = $email->config['notification_status_editable']; |
97 | 97 | |
98 | 98 | return (bool) $user_can_edit; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return bool |
110 | 110 | */ |
111 | - public static function is_content_type_editable( Give_Email_Notification $email ) { |
|
111 | + public static function is_content_type_editable(Give_Email_Notification $email) { |
|
112 | 112 | return $email->config['content_type_editable']; |
113 | 113 | } |
114 | 114 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return bool |
124 | 124 | */ |
125 | - public static function is_email_preview_has_header( Give_Email_Notification $email ) { |
|
125 | + public static function is_email_preview_has_header(Give_Email_Notification $email) { |
|
126 | 126 | return $email->config['has_preview_header']; |
127 | 127 | } |
128 | 128 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return bool |
138 | 138 | */ |
139 | - public static function is_email_preview( Give_Email_Notification $email ) { |
|
139 | + public static function is_email_preview(Give_Email_Notification $email) { |
|
140 | 140 | return $email->config['has_preview']; |
141 | 141 | } |
142 | 142 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return bool |
152 | 152 | */ |
153 | - public static function is_show_on_emails_setting_page( Give_Email_Notification $email ){ |
|
153 | + public static function is_show_on_emails_setting_page(Give_Email_Notification $email) { |
|
154 | 154 | return $email->config['show_on_emails_setting_page']; |
155 | 155 | } |
156 | 156 | |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return bool |
167 | 167 | */ |
168 | - public static function can_use_form_email_options( Give_Email_Notification $email, $form_id = null ){ |
|
169 | - return give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) ); |
|
168 | + public static function can_use_form_email_options(Give_Email_Notification $email, $form_id = null) { |
|
169 | + return give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true)); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string |
182 | 182 | */ |
183 | - public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) { |
|
184 | - $notification_status = $email->get_notification_status( $form_id ); |
|
183 | + public static function is_email_notification_active(Give_Email_Notification $email, $form_id = null) { |
|
184 | + $notification_status = $email->get_notification_status($form_id); |
|
185 | 185 | |
186 | 186 | |
187 | - $notification_status = empty( $form_id ) |
|
188 | - ? give_is_setting_enabled( $notification_status ) |
|
189 | - : give_is_setting_enabled( give_get_option( "{$email->config['id']}_notification", $email->config['notification_status'] ) ) && give_is_setting_enabled( $notification_status, array( 'enabled', 'global' ) ); |
|
187 | + $notification_status = empty($form_id) |
|
188 | + ? give_is_setting_enabled($notification_status) |
|
189 | + : give_is_setting_enabled(give_get_option("{$email->config['id']}_notification", $email->config['notification_status'])) && give_is_setting_enabled($notification_status, array('enabled', 'global')); |
|
190 | 190 | // To check if email notification is active or not on a per-form basis, email notification must be globally active—otherwise it will be considered disabled. |
191 | 191 | |
192 | 192 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param bool $notification_status True if notification is enable and false when disable |
202 | 202 | */ |
203 | - return apply_filters( "give_{$email->config['id']}_is_email_notification_active", $notification_status, $email, $form_id ); |
|
203 | + return apply_filters("give_{$email->config['id']}_is_email_notification_active", $notification_status, $email, $form_id); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | $is_preview = false; |
215 | 215 | |
216 | 216 | if ( |
217 | - current_user_can( 'manage_give_settings' ) |
|
218 | - && ! empty( $_GET['give_action'] ) |
|
217 | + current_user_can('manage_give_settings') |
|
218 | + && ! empty($_GET['give_action']) |
|
219 | 219 | && 'preview_email' === $_GET['give_action'] |
220 | 220 | ) { |
221 | 221 | $is_preview = true; |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | $is_preview = false; |
236 | 236 | |
237 | 237 | if ( |
238 | - current_user_can( 'manage_give_settings' ) |
|
239 | - && ! empty( $_GET['give_action'] ) |
|
238 | + current_user_can('manage_give_settings') |
|
239 | + && ! empty($_GET['give_action']) |
|
240 | 240 | && 'send_preview_email' === $_GET['give_action'] |
241 | 241 | ) { |
242 | 242 | $is_preview = true; |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return string |
258 | 258 | */ |
259 | - public static function get_formatted_email_type( $content_type ) { |
|
259 | + public static function get_formatted_email_type($content_type) { |
|
260 | 260 | $email_contents = array( |
261 | - 'text/html' => __( 'HTML', 'give' ), |
|
262 | - 'text/plain' => __( 'Plain', 'give' ), |
|
261 | + 'text/html' => __('HTML', 'give'), |
|
262 | + 'text/plain' => __('Plain', 'give'), |
|
263 | 263 | ); |
264 | 264 | |
265 | - return $email_contents[ $content_type ]; |
|
265 | + return $email_contents[$content_type]; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -279,41 +279,41 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @return mixed |
281 | 281 | */ |
282 | - public static function get_value( Give_Email_Notification $email, $option_name, $form_id = null, $default = false ) { |
|
282 | + public static function get_value(Give_Email_Notification $email, $option_name, $form_id = null, $default = false) { |
|
283 | 283 | // If form id set then option name can be contain _give_ prefix which is only used for meta key, |
284 | 284 | // So make sure you are using correct option name. |
285 | - $global_option_name = ( 0 === strpos( $option_name, '_give_' ) |
|
286 | - ? str_replace( '_give_', '', $option_name ) |
|
287 | - : $option_name ); |
|
288 | - $option_value = give_get_option( $global_option_name, $default ); |
|
285 | + $global_option_name = (0 === strpos($option_name, '_give_') |
|
286 | + ? str_replace('_give_', '', $option_name) |
|
287 | + : $option_name); |
|
288 | + $option_value = give_get_option($global_option_name, $default); |
|
289 | 289 | |
290 | 290 | if ( |
291 | - ! empty( $form_id ) |
|
291 | + ! empty($form_id) |
|
292 | 292 | && give_is_setting_enabled( |
293 | 293 | give_get_meta( |
294 | 294 | $form_id, |
295 | - Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'notification', |
|
295 | + Give_Email_Setting_Field::get_prefix($email, $form_id).'notification', |
|
296 | 296 | true, |
297 | 297 | 'global' |
298 | 298 | ) |
299 | 299 | ) |
300 | 300 | ) { |
301 | - $option_value = get_post_meta( $form_id, $option_name, true ); |
|
301 | + $option_value = get_post_meta($form_id, $option_name, true); |
|
302 | 302 | |
303 | 303 | // Get only email field value from recipients setting. |
304 | - if( Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'recipient' === $option_name ) { |
|
305 | - $option_value = wp_list_pluck( $option_value, 'email' ); |
|
304 | + if (Give_Email_Setting_Field::get_prefix($email, $form_id).'recipient' === $option_name) { |
|
305 | + $option_value = wp_list_pluck($option_value, 'email'); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - $option_value = empty( $option_value ) ? $default : $option_value; |
|
309 | + $option_value = empty($option_value) ? $default : $option_value; |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Filter the setting value |
313 | 313 | * |
314 | 314 | * @since 2.0 |
315 | 315 | */ |
316 | - return apply_filters( 'give_email_setting_value', $option_value, $option_name, $email, $form_id, $default ); |
|
316 | + return apply_filters('give_email_setting_value', $option_value, $option_name, $email, $form_id, $default); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -328,12 +328,12 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - public static function get_email_logo( $form_id ) { |
|
331 | + public static function get_email_logo($form_id) { |
|
332 | 332 | |
333 | 333 | // Email logo tag. |
334 | - $header_img = $form_id && give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) ) |
|
335 | - ? give_get_meta( $form_id, '_give_email_logo', true ) |
|
336 | - : give_get_option( 'email_logo', '' ); |
|
334 | + $header_img = $form_id && give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true)) |
|
335 | + ? give_get_meta($form_id, '_give_email_logo', true) |
|
336 | + : give_get_option('email_logo', ''); |
|
337 | 337 | |
338 | 338 | return $header_img; |
339 | 339 | } |