@@ -85,7 +85,7 @@ |
||
85 | 85 | * |
86 | 86 | * @since 1.8 |
87 | 87 | * |
88 | - * @param $setting_tab |
|
88 | + * @param string $setting_tab |
|
89 | 89 | * |
90 | 90 | * @return string |
91 | 91 | */ |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! class_exists( 'Give_CMB2_Settings_Loader' ) ) : |
|
12 | +if ( ! class_exists('Give_CMB2_Settings_Loader')) : |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * This class loads the cmb2 settings. |
@@ -52,30 +52,30 @@ discard block |
||
52 | 52 | |
53 | 53 | // Get current tab. |
54 | 54 | $this->current_tab = give_get_current_setting_tab(); |
55 | - $this->current_section = empty( $_REQUEST['section'] ) ? ( current( array_keys( $this->get_sections() ) ) ) : sanitize_title( $_REQUEST['section'] ); |
|
55 | + $this->current_section = empty($_REQUEST['section']) ? (current(array_keys($this->get_sections()))) : sanitize_title($_REQUEST['section']); |
|
56 | 56 | |
57 | 57 | // Tab ID. |
58 | 58 | $this->id = $this->current_tab; |
59 | 59 | |
60 | 60 | // Add addon tabs. |
61 | - add_filter( 'give-settings_tabs_array', array( $this, 'add_addon_settings_page' ), 999999 ); |
|
61 | + add_filter('give-settings_tabs_array', array($this, 'add_addon_settings_page'), 999999); |
|
62 | 62 | |
63 | 63 | // Add save hook to addons. |
64 | - add_action( 'give-settings_get_settings_pages', array( $this, 'setup_addon_save_hook' ), 999999 ); |
|
64 | + add_action('give-settings_get_settings_pages', array($this, 'setup_addon_save_hook'), 999999); |
|
65 | 65 | |
66 | 66 | // Add backward compatibility filters plugin settings. |
67 | - $setting_tabs = array( 'general', 'gateways', 'display', 'emails', 'addons', 'licenses' ); |
|
67 | + $setting_tabs = array('general', 'gateways', 'display', 'emails', 'addons', 'licenses'); |
|
68 | 68 | |
69 | 69 | // Filter Payment Gateways settings. |
70 | - if ( in_array( $this->current_tab, $setting_tabs ) ) { |
|
71 | - add_filter( "give_get_settings_{$this->current_tab}", array( |
|
70 | + if (in_array($this->current_tab, $setting_tabs)) { |
|
71 | + add_filter("give_get_settings_{$this->current_tab}", array( |
|
72 | 72 | $this, |
73 | 73 | 'get_filtered_addon_settings', |
74 | - ), 999999, 1 ); |
|
75 | - add_filter( "give_get_sections_{$this->current_tab}", array( |
|
74 | + ), 999999, 1); |
|
75 | + add_filter("give_get_sections_{$this->current_tab}", array( |
|
76 | 76 | $this, |
77 | 77 | 'get_filtered_addon_sections', |
78 | - ), 999999, 1 ); |
|
78 | + ), 999999, 1); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string |
90 | 90 | */ |
91 | - function set_default_setting_tab( $setting_tab ) { |
|
91 | + function set_default_setting_tab($setting_tab) { |
|
92 | 92 | $default_tab = ''; |
93 | 93 | |
94 | 94 | // Set default tab to first setting tab. |
95 | - if ( $sections = array_keys( $this->get_sections() ) ) { |
|
96 | - $default_tab = current( $sections ); |
|
95 | + if ($sections = array_keys($this->get_sections())) { |
|
96 | + $default_tab = current($sections); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return $default_tab; |
@@ -108,29 +108,29 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return mixed |
110 | 110 | */ |
111 | - function add_addon_settings_page( $pages ) { |
|
111 | + function add_addon_settings_page($pages) { |
|
112 | 112 | // Previous setting page. |
113 | 113 | $previous_pages = $this->prev_settings->give_get_settings_tabs(); |
114 | 114 | |
115 | 115 | // API and System Info setting tab merge to Tools setting tab, so remove them from tabs. |
116 | - unset( $previous_pages['api'] ); |
|
117 | - unset( $previous_pages['system_info'] ); |
|
116 | + unset($previous_pages['api']); |
|
117 | + unset($previous_pages['system_info']); |
|
118 | 118 | |
119 | 119 | // Tab is not register. |
120 | - $pages_diff = array_keys( array_diff( $previous_pages, $pages ) ); |
|
120 | + $pages_diff = array_keys(array_diff($previous_pages, $pages)); |
|
121 | 121 | |
122 | 122 | // Merge old settings with new settings. |
123 | - $pages = array_merge( $pages, $previous_pages ); |
|
123 | + $pages = array_merge($pages, $previous_pages); |
|
124 | 124 | |
125 | - if ( in_array( $this->current_tab, $pages_diff ) ) { |
|
125 | + if (in_array($this->current_tab, $pages_diff)) { |
|
126 | 126 | // Filter & actions. |
127 | - add_filter( "give_default_setting_tab_section_{$this->current_tab}", array( |
|
127 | + add_filter("give_default_setting_tab_section_{$this->current_tab}", array( |
|
128 | 128 | $this, |
129 | 129 | 'set_default_setting_tab', |
130 | - ), 10 ); |
|
131 | - add_action( "give-settings_sections_{$this->current_tab}_page", array( $this, 'output_sections' ) ); |
|
132 | - add_action( "give-settings_settings_{$this->current_tab}_page", array( $this, 'output' ), 10 ); |
|
133 | - add_action( "give-settings_save_{$this->current_tab}", array( $this, 'save' ) ); |
|
130 | + ), 10); |
|
131 | + add_action("give-settings_sections_{$this->current_tab}_page", array($this, 'output_sections')); |
|
132 | + add_action("give-settings_settings_{$this->current_tab}_page", array($this, 'output'), 10); |
|
133 | + add_action("give-settings_save_{$this->current_tab}", array($this, 'save')); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | return $pages; |
@@ -146,29 +146,29 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return mixed |
148 | 148 | */ |
149 | - function setup_addon_save_hook( $pages ) { |
|
149 | + function setup_addon_save_hook($pages) { |
|
150 | 150 | $page_ids = array(); |
151 | 151 | |
152 | - foreach ( $pages as $page ) { |
|
153 | - $page_ids = $page->add_settings_page( $page_ids ); |
|
152 | + foreach ($pages as $page) { |
|
153 | + $page_ids = $page->add_settings_page($page_ids); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // Previous setting page. |
157 | 157 | $previous_pages = $this->prev_settings->give_get_settings_tabs(); |
158 | 158 | |
159 | 159 | // API and System Info setting tab merge to Tools setting tab, so remove them from tabs. |
160 | - unset( $previous_pages['api'] ); |
|
161 | - unset( $previous_pages['system_info'] ); |
|
160 | + unset($previous_pages['api']); |
|
161 | + unset($previous_pages['system_info']); |
|
162 | 162 | |
163 | 163 | // Tab is not register. |
164 | - $pages_diff = array_keys( array_diff( $previous_pages, $page_ids ) ); |
|
164 | + $pages_diff = array_keys(array_diff($previous_pages, $page_ids)); |
|
165 | 165 | |
166 | 166 | // Merge old settings with new settings. |
167 | - $pages = array_merge( $page_ids, $previous_pages ); |
|
167 | + $pages = array_merge($page_ids, $previous_pages); |
|
168 | 168 | |
169 | - if ( in_array( $this->current_tab, $pages_diff ) ) { |
|
169 | + if (in_array($this->current_tab, $pages_diff)) { |
|
170 | 170 | // Filter & actions. |
171 | - add_action( "give-settings_save_{$this->current_tab}", array( $this, 'save' ) ); |
|
171 | + add_action("give-settings_save_{$this->current_tab}", array($this, 'save')); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $pages; |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - function get_section_name( $field_name ) { |
|
186 | + function get_section_name($field_name) { |
|
187 | 187 | // Bailout. |
188 | - if ( empty( $field_name ) ) { |
|
188 | + if (empty($field_name)) { |
|
189 | 189 | return $field_name; |
190 | 190 | } |
191 | 191 | |
192 | - $section_name = explode( ' ', $field_name ); |
|
192 | + $section_name = explode(' ', $field_name); |
|
193 | 193 | |
194 | 194 | // Output. |
195 | - return strip_tags( implode( ' ', $section_name ) ); |
|
195 | + return strip_tags(implode(' ', $section_name)); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -205,39 +205,39 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return mixed |
207 | 207 | */ |
208 | - function get_filtered_addon_sections( $sections = array() ) { |
|
208 | + function get_filtered_addon_sections($sections = array()) { |
|
209 | 209 | // New sections. |
210 | 210 | $new_sections = array(); |
211 | - $sections_ID = array_keys( $sections ); |
|
211 | + $sections_ID = array_keys($sections); |
|
212 | 212 | |
213 | - if ( ( $setting_fields = $this->prev_settings->give_settings( $this->current_tab ) ) && ! empty( $setting_fields['fields'] ) ) { |
|
213 | + if (($setting_fields = $this->prev_settings->give_settings($this->current_tab)) && ! empty($setting_fields['fields'])) { |
|
214 | 214 | |
215 | - foreach ( $setting_fields['fields'] as $field ) { |
|
215 | + foreach ($setting_fields['fields'] as $field) { |
|
216 | 216 | // Section name. |
217 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : ''; |
|
218 | - $section_name = $this->get_section_name( $field['name'] ); |
|
217 | + $field['name'] = isset($field['name']) ? $field['name'] : ''; |
|
218 | + $section_name = $this->get_section_name($field['name']); |
|
219 | 219 | |
220 | 220 | // Check if section name exit and section title array is not empty. |
221 | - if ( ! empty( $sections ) && ! empty( $field['name'] ) ) { |
|
221 | + if ( ! empty($sections) && ! empty($field['name'])) { |
|
222 | 222 | |
223 | 223 | // Bailout: Do not load section if it is already exist. |
224 | 224 | if ( |
225 | - in_array( sanitize_title( $field['name'] ), $sections_ID ) // Check section id. |
|
226 | - || in_array( $section_name, $sections ) // Check section name. |
|
225 | + in_array(sanitize_title($field['name']), $sections_ID) // Check section id. |
|
226 | + || in_array($section_name, $sections) // Check section name. |
|
227 | 227 | ) { |
228 | 228 | continue; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | // Collect new sections from addons. |
233 | - if ( 'give_title' == $field['type'] ) { |
|
234 | - $new_sections[ sanitize_title( $field['name'] ) ] = $section_name; |
|
233 | + if ('give_title' == $field['type']) { |
|
234 | + $new_sections[sanitize_title($field['name'])] = $section_name; |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Add new section. |
240 | - $sections = array_merge( $sections, $new_sections ); |
|
240 | + $sections = array_merge($sections, $new_sections); |
|
241 | 241 | |
242 | 242 | // Output. |
243 | 243 | return $sections; |
@@ -254,19 +254,19 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return array |
256 | 256 | */ |
257 | - function get_filtered_addon_settings( $settings, $setting_fields = array() ) { |
|
257 | + function get_filtered_addon_settings($settings, $setting_fields = array()) { |
|
258 | 258 | global $wp_filter; |
259 | 259 | |
260 | 260 | $new_setting_fields = array(); |
261 | 261 | |
262 | - if ( ! empty( $settings ) ) { |
|
262 | + if ( ! empty($settings)) { |
|
263 | 263 | // Bailout: If setting array contain first element of type title then it means it is already created with new setting api (skip this section ). |
264 | - if ( isset( $settings[0]['type'] ) && 'title' == $settings[0]['type'] ) { |
|
265 | - foreach ( $settings as $setting ) { |
|
264 | + if (isset($settings[0]['type']) && 'title' == $settings[0]['type']) { |
|
265 | + foreach ($settings as $setting) { |
|
266 | 266 | $new_setting_fields[] = $setting; |
267 | 267 | |
268 | 268 | // We need setting only till first section end. |
269 | - if ( 'sectionend' === $setting['type'] ) { |
|
269 | + if ('sectionend' === $setting['type']) { |
|
270 | 270 | break; |
271 | 271 | } |
272 | 272 | } |
@@ -278,24 +278,24 @@ discard block |
||
278 | 278 | $prev_title_field_id = ''; |
279 | 279 | |
280 | 280 | // Create new setting fields. |
281 | - foreach ( $settings as $index => $field ) { |
|
281 | + foreach ($settings as $index => $field) { |
|
282 | 282 | |
283 | 283 | // Bailout: Must need field type to process. |
284 | - if ( ! isset( $field['type'] ) ) { |
|
284 | + if ( ! isset($field['type'])) { |
|
285 | 285 | continue; |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Set wrapper class if any. |
289 | - if ( ! empty( $field['row_classes'] ) ) { |
|
289 | + if ( ! empty($field['row_classes'])) { |
|
290 | 290 | $field['wrapper_class'] = $field['row_classes']; |
291 | - unset( $field['row_classes'] ); |
|
291 | + unset($field['row_classes']); |
|
292 | 292 | } |
293 | 293 | |
294 | - $field['name'] = ! isset( $field['name'] ) ? '' : $field['name']; |
|
295 | - $field['desc'] = ! isset( $field['desc'] ) ? '' : $field['desc']; |
|
294 | + $field['name'] = ! isset($field['name']) ? '' : $field['name']; |
|
295 | + $field['desc'] = ! isset($field['desc']) ? '' : $field['desc']; |
|
296 | 296 | |
297 | 297 | // Modify cmb2 setting fields. |
298 | - switch ( $field['type'] ) { |
|
298 | + switch ($field['type']) { |
|
299 | 299 | case 'text' : |
300 | 300 | case 'file' : |
301 | 301 | $field['css'] = 'width:25em;'; |
@@ -319,18 +319,18 @@ discard block |
||
319 | 319 | $field['type'] = 'title'; |
320 | 320 | |
321 | 321 | // Since we are showing sections, so there now ned to show horizontal rules. |
322 | - if ( '<hr>' === $field['desc'] ) { |
|
322 | + if ('<hr>' === $field['desc']) { |
|
323 | 323 | $field['desc'] = ''; |
324 | 324 | } |
325 | 325 | |
326 | 326 | break; |
327 | 327 | } |
328 | 328 | |
329 | - if ( 'title' === $field['type'] ) { |
|
329 | + if ('title' === $field['type']) { |
|
330 | 330 | |
331 | 331 | // If we do not have first element as title then these field will be skip from frontend |
332 | 332 | // because there are not belong to any section, so put all abandon fields under first section. |
333 | - if ( $index && empty( $prev_title_field_id ) ) { |
|
333 | + if ($index && empty($prev_title_field_id)) { |
|
334 | 334 | array_unshift( |
335 | 335 | $new_setting_fields, |
336 | 336 | array( |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | $prev_title_field_id = $field['id']; |
345 | 345 | |
346 | 346 | continue; |
347 | - } elseif ( $index ) { |
|
347 | + } elseif ($index) { |
|
348 | 348 | // Section end. |
349 | 349 | $new_setting_fields[] = array( |
350 | 350 | 'type' => 'sectionend', |
@@ -376,52 +376,52 @@ discard block |
||
376 | 376 | |
377 | 377 | // Check if setting page has title section or not. |
378 | 378 | // If setting page does not have title section then add title section to it and fix section end array id. |
379 | - if ( 'title' !== $new_setting_fields[0]['type'] ) { |
|
379 | + if ('title' !== $new_setting_fields[0]['type']) { |
|
380 | 380 | array_unshift( |
381 | 381 | $new_setting_fields, |
382 | 382 | array( |
383 | - 'title' => ( isset( $settings['give_title'] ) ? $settings['give_title'] : '' ), |
|
383 | + 'title' => (isset($settings['give_title']) ? $settings['give_title'] : ''), |
|
384 | 384 | 'type' => 'title', |
385 | - 'desc' => ! empty( $setting_fields['desc'] ) ? $setting_fields['desc'] : '', |
|
386 | - 'id' => ( isset( $settings['id'] ) ? $settings['id'] : '' ), |
|
385 | + 'desc' => ! empty($setting_fields['desc']) ? $setting_fields['desc'] : '', |
|
386 | + 'id' => (isset($settings['id']) ? $settings['id'] : ''), |
|
387 | 387 | ) |
388 | 388 | ); |
389 | 389 | |
390 | 390 | // Update id in section end array if does not contain. |
391 | - if ( empty( $new_setting_fields[ count( $new_setting_fields ) - 1 ]['id'] ) ) { |
|
392 | - $new_setting_fields[ count( $new_setting_fields ) - 1 ]['id'] = ( isset( $settings['id'] ) ? $settings['id'] : '' ); |
|
391 | + if (empty($new_setting_fields[count($new_setting_fields) - 1]['id'])) { |
|
392 | + $new_setting_fields[count($new_setting_fields) - 1]['id'] = (isset($settings['id']) ? $settings['id'] : ''); |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Return only section related settings. |
397 | - if ( $sections = $this->get_filtered_addon_sections() ) { |
|
398 | - $new_setting_fields = $this->get_section_settings( $new_setting_fields ); |
|
397 | + if ($sections = $this->get_filtered_addon_sections()) { |
|
398 | + $new_setting_fields = $this->get_section_settings($new_setting_fields); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | // Third party plugin backward compatibility. |
402 | - $wp_filter_keys = array_keys( $wp_filter ); |
|
403 | - foreach ( $new_setting_fields as $index => $field ) { |
|
404 | - if ( ! isset( $field['type'] ) || in_array( $field['type'], array( 'title', 'sectionend' ) ) ) { |
|
402 | + $wp_filter_keys = array_keys($wp_filter); |
|
403 | + foreach ($new_setting_fields as $index => $field) { |
|
404 | + if ( ! isset($field['type']) || in_array($field['type'], array('title', 'sectionend'))) { |
|
405 | 405 | continue; |
406 | 406 | } |
407 | 407 | |
408 | 408 | $cmb2_filter_name = "cmb2_render_{$field['type']}"; |
409 | 409 | |
410 | - if ( in_array( $cmb2_filter_name, $wp_filter_keys ) ) { |
|
410 | + if (in_array($cmb2_filter_name, $wp_filter_keys)) { |
|
411 | 411 | |
412 | - if ( 0 >= version_compare( 4.7, get_bloginfo( 'version' ) ) && ! empty( $wp_filter[ $cmb2_filter_name ]->callbacks ) ) { |
|
413 | - $cmb2_filter_arr = current( $wp_filter[ $cmb2_filter_name ]->callbacks ); |
|
412 | + if (0 >= version_compare(4.7, get_bloginfo('version')) && ! empty($wp_filter[$cmb2_filter_name]->callbacks)) { |
|
413 | + $cmb2_filter_arr = current($wp_filter[$cmb2_filter_name]->callbacks); |
|
414 | 414 | } else { |
415 | - $cmb2_filter_arr = current( $wp_filter[ $cmb2_filter_name ] ); |
|
415 | + $cmb2_filter_arr = current($wp_filter[$cmb2_filter_name]); |
|
416 | 416 | } |
417 | 417 | |
418 | - if ( ! empty( $cmb2_filter_arr ) ) { |
|
418 | + if ( ! empty($cmb2_filter_arr)) { |
|
419 | 419 | // Note: function can be called either globally or with class object, it depends on how developer invoke it. |
420 | - $new_setting_fields[ $index ]['func'] = current( $cmb2_filter_arr ); |
|
421 | - add_action( "give_admin_field_{$field['type']}", array( |
|
420 | + $new_setting_fields[$index]['func'] = current($cmb2_filter_arr); |
|
421 | + add_action("give_admin_field_{$field['type']}", array( |
|
422 | 422 | $this, |
423 | 423 | 'addon_setting_field', |
424 | - ), 10, 2 ); |
|
424 | + ), 10, 2); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | } |
@@ -442,31 +442,31 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return array |
444 | 444 | */ |
445 | - function get_section_settings( $tab_settings ) { |
|
445 | + function get_section_settings($tab_settings) { |
|
446 | 446 | $current_section = give_get_current_setting_section(); |
447 | 447 | |
448 | 448 | // Note: If we are opening default tabe for addon setting then it is possible that we will get empty string as current section |
449 | 449 | // because default section filter added after save hook fire, so we will always get problem to save first section [default] or if there are only on section |
450 | 450 | // This is hack to fix this. |
451 | - if ( empty( $current_section ) ) { |
|
452 | - $current_section = $this->set_default_setting_tab( $current_section ); |
|
451 | + if (empty($current_section)) { |
|
452 | + $current_section = $this->set_default_setting_tab($current_section); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | $section_start = false; |
456 | 456 | $section_end = false; |
457 | 457 | $section_only_setting_fields = array(); |
458 | 458 | |
459 | - foreach ( $tab_settings as $field ) { |
|
460 | - if ( 'title' == $field['type'] && $current_section == sanitize_title( $field['title'] ) ) { |
|
459 | + foreach ($tab_settings as $field) { |
|
460 | + if ('title' == $field['type'] && $current_section == sanitize_title($field['title'])) { |
|
461 | 461 | $section_start = true; |
462 | 462 | } |
463 | 463 | |
464 | - if ( ! $section_start || $section_end ) { |
|
464 | + if ( ! $section_start || $section_end) { |
|
465 | 465 | continue; |
466 | 466 | } |
467 | 467 | |
468 | - if ( $section_start && ! $section_end ) { |
|
469 | - if ( 'sectionend' == $field['type'] ) { |
|
468 | + if ($section_start && ! $section_end) { |
|
469 | + if ('sectionend' == $field['type']) { |
|
470 | 470 | $section_end = true; |
471 | 471 | } |
472 | 472 | $section_only_setting_fields[] = $field; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | // Remove title from setting, pevent it from render in setting tab. |
477 | 477 | $section_only_setting_fields[0]['title'] = ''; |
478 | 478 | |
479 | - return apply_filters( "give_get_settings_{$this->current_tab}_{$current_section}", $section_only_setting_fields, $tab_settings ); |
|
479 | + return apply_filters("give_get_settings_{$this->current_tab}_{$current_section}", $section_only_setting_fields, $tab_settings); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | |
@@ -490,17 +490,17 @@ discard block |
||
490 | 490 | * |
491 | 491 | * @return void |
492 | 492 | */ |
493 | - function addon_setting_field( $field, $saved_value ) { |
|
493 | + function addon_setting_field($field, $saved_value) { |
|
494 | 494 | // Create object for cmb2 function callback backward compatibility. |
495 | 495 | // Note: Do not call any cmb2 function on these objects |
496 | - $field_obj = (object) array( 'args' => $field ); |
|
497 | - $field_type_obj = (object) array( 'field' => $field_obj ); |
|
496 | + $field_obj = (object) array('args' => $field); |
|
497 | + $field_type_obj = (object) array('field' => $field_obj); |
|
498 | 498 | |
499 | - switch ( $this->current_tab ) : |
|
499 | + switch ($this->current_tab) : |
|
500 | 500 | case 'licenses': |
501 | 501 | ?> |
502 | 502 | <div class="give-settings-wrap give-settings-wrap-<?php echo $this->current_tab; ?>"> |
503 | - <?php $field['func']['function']( $field_obj, $saved_value, '', '', $field_type_obj ); ?> |
|
503 | + <?php $field['func']['function']($field_obj, $saved_value, '', '', $field_type_obj); ?> |
|
504 | 504 | </div> |
505 | 505 | <?php break; |
506 | 506 | |
@@ -508,19 +508,19 @@ discard block |
||
508 | 508 | $colspan = 'colspan="2"'; |
509 | 509 | ?> |
510 | 510 | <tr valign="top"> |
511 | - <?php if ( ! empty( $field['name'] ) && ! in_array( $field['name'], array( ' ' ) ) ) : ?> |
|
511 | + <?php if ( ! empty($field['name']) && ! in_array($field['name'], array(' '))) : ?> |
|
512 | 512 | <th scope="row" class="titledesc"> |
513 | 513 | <label |
514 | - for="<?php echo esc_attr( $field['name'] ); ?>"><?php echo $field['title']; ?></label> |
|
514 | + for="<?php echo esc_attr($field['name']); ?>"><?php echo $field['title']; ?></label> |
|
515 | 515 | </th> |
516 | 516 | <?php $colspan = ''; ?> |
517 | 517 | <?php endif; ?> |
518 | 518 | <td class="give-forminp" <?php echo $colspan; ?>> |
519 | 519 | <?php |
520 | - if ( is_array( $field['func']['function'] ) ) { |
|
521 | - $field['func']['function'][0]->$field['func']['function'][1]( $field_obj, $saved_value, '', '', $field_type_obj ); |
|
520 | + if (is_array($field['func']['function'])) { |
|
521 | + $field['func']['function'][0]->$field['func']['function'][1]($field_obj, $saved_value, '', '', $field_type_obj); |
|
522 | 522 | } else { |
523 | - $field['func']['function']( $field_obj, $saved_value, '', '', $field_type_obj ); |
|
523 | + $field['func']['function']($field_obj, $saved_value, '', '', $field_type_obj); |
|
524 | 524 | } |
525 | 525 | ?> |
526 | 526 | </td> |
@@ -538,10 +538,10 @@ discard block |
||
538 | 538 | public function get_sections() { |
539 | 539 | $sections = array(); |
540 | 540 | |
541 | - if ( ( $setting_fields = $this->prev_settings->give_settings( $this->current_tab ) ) && ! empty( $setting_fields['fields'] ) ) { |
|
542 | - foreach ( $setting_fields['fields'] as $field ) { |
|
543 | - if ( 'give_title' == $field['type'] ) { |
|
544 | - $sections[ sanitize_title( $field['name'] ) ] = $this->get_section_name( $field['name'] ); |
|
541 | + if (($setting_fields = $this->prev_settings->give_settings($this->current_tab)) && ! empty($setting_fields['fields'])) { |
|
542 | + foreach ($setting_fields['fields'] as $field) { |
|
543 | + if ('give_title' == $field['type']) { |
|
544 | + $sections[sanitize_title($field['name'])] = $this->get_section_name($field['name']); |
|
545 | 545 | } |
546 | 546 | } |
547 | 547 | } |
@@ -561,16 +561,16 @@ discard block |
||
561 | 561 | |
562 | 562 | $new_setting_fields = array(); |
563 | 563 | |
564 | - if ( $setting_fields = $this->prev_settings->give_settings( $this->current_tab ) ) { |
|
565 | - if ( isset( $setting_fields['fields'] ) ) { |
|
564 | + if ($setting_fields = $this->prev_settings->give_settings($this->current_tab)) { |
|
565 | + if (isset($setting_fields['fields'])) { |
|
566 | 566 | |
567 | 567 | $tab_data = array( |
568 | 568 | 'id' => $setting_fields['id'], |
569 | 569 | 'give_title' => $setting_fields['give_title'], |
570 | - 'desc' => ( isset( $setting_fields['desc'] ) ? $setting_fields['desc'] : '' ), |
|
570 | + 'desc' => (isset($setting_fields['desc']) ? $setting_fields['desc'] : ''), |
|
571 | 571 | ); |
572 | 572 | |
573 | - $new_setting_fields = $this->get_filtered_addon_settings( $setting_fields['fields'], $tab_data ); |
|
573 | + $new_setting_fields = $this->get_filtered_addon_settings($setting_fields['fields'], $tab_data); |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
@@ -587,24 +587,24 @@ discard block |
||
587 | 587 | $sections = $this->get_sections(); |
588 | 588 | |
589 | 589 | // Show section settings only if setting section exist. |
590 | - if ( $this->current_section && ! in_array( $this->current_section, array_keys( $sections ) ) ) { |
|
591 | - echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
590 | + if ($this->current_section && ! in_array($this->current_section, array_keys($sections))) { |
|
591 | + echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; |
|
592 | 592 | $GLOBALS['give_hide_save_button'] = true; |
593 | 593 | |
594 | 594 | return; |
595 | 595 | } |
596 | 596 | |
597 | 597 | // Bailout. |
598 | - if ( empty( $sections ) ) { |
|
598 | + if (empty($sections)) { |
|
599 | 599 | return; |
600 | 600 | } |
601 | 601 | |
602 | 602 | echo '<ul class="subsubsub">'; |
603 | 603 | |
604 | - $array_keys = array_keys( $sections ); |
|
604 | + $array_keys = array_keys($sections); |
|
605 | 605 | |
606 | - foreach ( $sections as $id => $label ) { |
|
607 | - echo '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=' . $this->current_tab . '§ion=' . sanitize_title( $id ) ) . '" class="' . ( $this->current_section == $id ? 'current' : '' ) . '">' . strip_tags( $label ) . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>'; |
|
606 | + foreach ($sections as $id => $label) { |
|
607 | + echo '<li><a href="'.admin_url('edit.php?post_type=give_forms&page=give-settings&tab='.$this->current_tab.'§ion='.sanitize_title($id)).'" class="'.($this->current_section == $id ? 'current' : '').'">'.strip_tags($label).'</a> '.(end($array_keys) == $id ? '' : '|').' </li>'; |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | echo '</ul><br class="clear" /><hr>'; |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | public function output() { |
620 | 620 | $settings = $this->get_settings(); |
621 | 621 | |
622 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
622 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | /** |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | public function save() { |
632 | 632 | $settings = $this->get_settings(); |
633 | 633 | |
634 | - Give_Admin_Settings::save_fields( $settings, 'give_settings' ); |
|
634 | + Give_Admin_Settings::save_fields($settings, 'give_settings'); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | endif; |
@@ -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 | |
@@ -36,29 +36,29 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * Templates |
38 | 38 | */ |
39 | - add_filter( 'template_include', array( __CLASS__, 'template_loader' ) ); |
|
39 | + add_filter('template_include', array(__CLASS__, 'template_loader')); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Content Wrappers |
43 | 43 | */ |
44 | - add_action( 'give_before_main_content', 'give_output_content_wrapper', 10 ); |
|
45 | - add_action( 'give_after_main_content', 'give_output_content_wrapper_end', 10 ); |
|
44 | + add_action('give_before_main_content', 'give_output_content_wrapper', 10); |
|
45 | + add_action('give_after_main_content', 'give_output_content_wrapper_end', 10); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Entry Summary Classes |
49 | 49 | */ |
50 | - add_filter( 'give_forms_single_summary_classes', array( $this, 'give_set_single_summary_classes' ) ); |
|
50 | + add_filter('give_forms_single_summary_classes', array($this, 'give_set_single_summary_classes')); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Sidebar |
54 | 54 | */ |
55 | - add_action( 'give_before_single_form_summary', array( $this, 'give_output_sidebar_option' ), 1 ); |
|
55 | + add_action('give_before_single_form_summary', array($this, 'give_output_sidebar_option'), 1); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Single Forms Summary Box |
59 | 59 | */ |
60 | - add_action( 'give_single_form_summary', 'give_template_single_title', 5 ); |
|
61 | - add_action( 'give_single_form_summary', 'give_get_donation_form', 10 ); |
|
60 | + add_action('give_single_form_summary', 'give_template_single_title', 5); |
|
61 | + add_action('give_single_form_summary', 'give_get_donation_form', 10); |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string $classes List of space separated class names. |
75 | 75 | */ |
76 | - public function give_set_single_summary_classes( $classes ) { |
|
76 | + public function give_set_single_summary_classes($classes) { |
|
77 | 77 | |
78 | 78 | //Add full width class when feature image is disabled AND no widgets are present |
79 | - if ( ! give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) ) { |
|
79 | + if ( ! give_is_setting_enabled(give_get_option('form_sidebar'))) { |
|
80 | 80 | $classes .= ' give-full-width'; |
81 | 81 | } |
82 | 82 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | public function give_output_sidebar_option() { |
98 | 98 | |
99 | 99 | //Add full width class when feature image is disabled AND no widgets are present |
100 | - if ( give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) ) { |
|
101 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5 ); |
|
102 | - add_action( 'give_before_single_form_summary', 'give_show_form_images', 10 ); |
|
103 | - add_action( 'give_before_single_form_summary', 'give_get_forms_sidebar', 20 ); |
|
104 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30 ); |
|
100 | + if (give_is_setting_enabled(give_get_option('form_sidebar'))) { |
|
101 | + add_action('give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5); |
|
102 | + add_action('give_before_single_form_summary', 'give_show_form_images', 10); |
|
103 | + add_action('give_before_single_form_summary', 'give_get_forms_sidebar', 20); |
|
104 | + add_action('give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | } |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return string $template |
125 | 125 | */ |
126 | - public static function template_loader( $template ) { |
|
127 | - $find = array( 'give.php' ); |
|
126 | + public static function template_loader($template) { |
|
127 | + $find = array('give.php'); |
|
128 | 128 | $file = ''; |
129 | 129 | |
130 | - if ( is_single() && get_post_type() == 'give_forms' ) { |
|
130 | + if (is_single() && get_post_type() == 'give_forms') { |
|
131 | 131 | $file = 'single-give-form.php'; |
132 | 132 | $find[] = $file; |
133 | - $find[] = apply_filters( 'give_template_path', 'give/' ) . $file; |
|
133 | + $find[] = apply_filters('give_template_path', 'give/').$file; |
|
134 | 134 | } |
135 | 135 | |
136 | - if ( $file ) { |
|
137 | - $template = locate_template( array_unique( $find ) ); |
|
138 | - if ( ! $template ) { |
|
139 | - $template = GIVE_PLUGIN_DIR . '/templates/' . $file; |
|
136 | + if ($file) { |
|
137 | + $template = locate_template(array_unique($find)); |
|
138 | + if ( ! $template) { |
|
139 | + $template = GIVE_PLUGIN_DIR.'/templates/'.$file; |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_tools_recount_stats_display() { |
24 | 24 | |
25 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
25 | + if ( ! current_user_can('manage_give_settings')) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @since 1.5 |
33 | 33 | */ |
34 | - do_action( 'give_tools_recount_stats_before' ); |
|
34 | + do_action('give_tools_recount_stats_before'); |
|
35 | 35 | ?> |
36 | 36 | <div id="poststuff"> |
37 | 37 | <div class="postbox"> |
38 | 38 | |
39 | - <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2> |
|
39 | + <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2> |
|
40 | 40 | |
41 | 41 | <div class="inside recount-stats-controls"> |
42 | - <p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
42 | + <p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p> |
|
43 | 43 | <form method="post" id="give-tools-recount-form" class="give-export-form"> |
44 | 44 | |
45 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
45 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
46 | 46 | |
47 | 47 | <select name="give-export-class" id="recount-stats-type"> |
48 | - <option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option> |
|
49 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
50 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option> |
|
51 | - <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option> |
|
52 | - <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
53 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Transactions', 'give' ); ?></option> |
|
54 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option> |
|
48 | + <option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option> |
|
49 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
50 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option> |
|
51 | + <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option> |
|
52 | + <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option> |
|
53 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Transactions', 'give'); ?></option> |
|
54 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option> |
|
55 | 55 | <?php |
56 | 56 | /** |
57 | 57 | * Fires in the recount stats selectbox. |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @since 1.5 |
62 | 62 | */ |
63 | - do_action( 'give_recount_tool_options' ); |
|
63 | + do_action('give_recount_tool_options'); |
|
64 | 64 | ?> |
65 | 65 | </select> |
66 | 66 | |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | <?php |
69 | 69 | $args = array( |
70 | 70 | 'name' => 'form_id', |
71 | - 'number' => - 1, |
|
71 | + 'number' => -1, |
|
72 | 72 | 'chosen' => true, |
73 | 73 | ); |
74 | - echo Give()->html->forms_dropdown( $args ); |
|
74 | + echo Give()->html->forms_dropdown($args); |
|
75 | 75 | ?> |
76 | 76 | </span> |
77 | 77 | |
78 | - <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
78 | + <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/> |
|
79 | 79 | |
80 | 80 | <br/> |
81 | 81 | |
82 | 82 | <span class="give-recount-stats-descriptions"> |
83 | - <span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
84 | - <span id="recount-form"><?php esc_html_e( 'Recalculates the donation and income stats for a specific form.', 'give' ); ?></span> |
|
85 | - <span id="recount-all"><?php esc_html_e( 'Recalculates the earnings and sales stats for all forms.', 'give' ); ?></span> |
|
86 | - <span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
83 | + <span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
84 | + <span id="recount-form"><?php esc_html_e('Recalculates the donation and income stats for a specific form.', 'give'); ?></span> |
|
85 | + <span id="recount-all"><?php esc_html_e('Recalculates the earnings and sales stats for all forms.', 'give'); ?></span> |
|
86 | + <span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
87 | 87 | <?php |
88 | 88 | /** |
89 | 89 | * Fires in the recount stats description area. |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @since 1.5 |
94 | 94 | */ |
95 | - do_action( 'give_recount_tool_descriptions' ); |
|
95 | + do_action('give_recount_tool_descriptions'); |
|
96 | 96 | ?> |
97 | - <span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give' ); ?></span> |
|
98 | - <span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span> |
|
97 | + <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give'); ?></span> |
|
98 | + <span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span> |
|
99 | 99 | </span> |
100 | 100 | |
101 | 101 | <span class="spinner"></span> |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @since 1.5 |
111 | 111 | */ |
112 | - do_action( 'give_tools_recount_forms' ); |
|
112 | + do_action('give_tools_recount_forms'); |
|
113 | 113 | ?> |
114 | 114 | </div><!-- .inside --> |
115 | 115 | </div><!-- .postbox --> |
@@ -120,5 +120,5 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @since 1.5 |
122 | 122 | */ |
123 | - do_action( 'give_tools_recount_stats_after' ); |
|
123 | + do_action('give_tools_recount_stats_after'); |
|
124 | 124 | } |
125 | 125 | \ No newline at end of file |
@@ -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_API' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_API')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_API. |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'api'; |
46 | - $this->label = esc_html__( 'API', 'give' ); |
|
46 | + $this->label = esc_html__('API', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param array $pages Lst of pages. |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function add_settings_page( $pages ) { |
|
60 | - $pages[ $this->id ] = $this->label; |
|
59 | + public function add_settings_page($pages) { |
|
60 | + $pages[$this->id] = $this->label; |
|
61 | 61 | |
62 | 62 | return $pages; |
63 | 63 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $GLOBALS['give_hide_save_button'] = true; |
74 | 74 | |
75 | 75 | // Get settings. |
76 | - $settings = apply_filters( 'give_settings_system', array( |
|
76 | + $settings = apply_filters('give_settings_system', array( |
|
77 | 77 | array( |
78 | 78 | 'id' => 'give_tools_api', |
79 | 79 | 'type' => 'title', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ), |
82 | 82 | array( |
83 | 83 | 'id' => 'api', |
84 | - 'name' => esc_html__( 'API', 'give' ), |
|
84 | + 'name' => esc_html__('API', 'give'), |
|
85 | 85 | 'type' => 'api', |
86 | 86 | ), |
87 | 87 | array( |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @since 1.8 |
98 | 98 | * @param array $settings |
99 | 99 | */ |
100 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
100 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
101 | 101 | |
102 | 102 | // Output. |
103 | 103 | return $settings; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function output() { |
113 | 113 | $settings = $this->get_settings(); |
114 | 114 | |
115 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
115 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 |
@@ -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_Data' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Data')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Data. |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'data'; |
46 | - $this->label = esc_html__( 'Data', 'give' ); |
|
46 | + $this->label = esc_html__('Data', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | |
51 | 51 | // Do not use main form for this tab. |
52 | - if( give_get_current_setting_tab() === $this->id ) { |
|
53 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
54 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
52 | + if (give_get_current_setting_tab() === $this->id) { |
|
53 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
54 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param array $pages Lst of pages. |
63 | 63 | * @return array |
64 | 64 | */ |
65 | - public function add_settings_page( $pages ) { |
|
66 | - $pages[ $this->id ] = $this->label; |
|
65 | + public function add_settings_page($pages) { |
|
66 | + $pages[$this->id] = $this->label; |
|
67 | 67 | |
68 | 68 | return $pages; |
69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $GLOBALS['give_hide_save_button'] = true; |
80 | 80 | |
81 | 81 | // Get settings. |
82 | - $settings = apply_filters( 'give_settings_system', array( |
|
82 | + $settings = apply_filters('give_settings_system', array( |
|
83 | 83 | array( |
84 | 84 | 'id' => 'give_tools_tools', |
85 | 85 | 'type' => 'title', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ), |
88 | 88 | array( |
89 | 89 | 'id' => 'api', |
90 | - 'name' => esc_html__( 'Tools', 'give' ), |
|
90 | + 'name' => esc_html__('Tools', 'give'), |
|
91 | 91 | 'type' => 'data', |
92 | 92 | ), |
93 | 93 | array( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @since 1.8 |
104 | 104 | * @param array $settings |
105 | 105 | */ |
106 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
106 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
107 | 107 | |
108 | 108 | // Output. |
109 | 109 | return $settings; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function output() { |
119 | 119 | $settings = $this->get_settings(); |
120 | 120 | |
121 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
121 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 |
@@ -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 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __setup_hooks() { |
45 | 45 | // Create the log post type |
46 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
46 | + add_action('init', array($this, 'register_post_type'), 1); |
|
47 | 47 | |
48 | 48 | // Create types taxonomy and default types |
49 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
49 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
50 | 50 | |
51 | - add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache') ); |
|
52 | - add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache') ); |
|
53 | - add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache') ); |
|
54 | - add_action( 'give_delete_log_cache', array( $this, 'delete_cache') ); |
|
51 | + add_action('save_post_give_payment', array($this, 'background_process_delete_cache')); |
|
52 | + add_action('save_post_give_forms', array($this, 'background_process_delete_cache')); |
|
53 | + add_action('save_post_give_log', array($this, 'background_process_delete_cache')); |
|
54 | + add_action('give_delete_log_cache', array($this, 'delete_cache')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function register_post_type() { |
68 | 68 | /* Logs post type */ |
69 | 69 | $log_args = array( |
70 | - 'labels' => array( 'name' => esc_html__( 'Logs', 'give' ) ), |
|
70 | + 'labels' => array('name' => esc_html__('Logs', 'give')), |
|
71 | 71 | 'public' => false, |
72 | 72 | 'exclude_from_search' => true, |
73 | 73 | 'publicly_queryable' => false, |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | 'query_var' => false, |
76 | 76 | 'rewrite' => false, |
77 | 77 | 'capability_type' => 'post', |
78 | - 'supports' => array( 'title', 'editor' ), |
|
78 | + 'supports' => array('title', 'editor'), |
|
79 | 79 | 'can_export' => true, |
80 | 80 | ); |
81 | 81 | |
82 | - register_post_type( 'give_log', $log_args ); |
|
82 | + register_post_type('give_log', $log_args); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @return void |
94 | 94 | */ |
95 | 95 | public function register_taxonomy() { |
96 | - register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) ); |
|
96 | + register_taxonomy('give_log_type', 'give_log', array('public' => false)); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'api_request', |
114 | 114 | ); |
115 | 115 | |
116 | - return apply_filters( 'give_log_types', $terms ); |
|
116 | + return apply_filters('give_log_types', $terms); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return bool Whether log type is valid. |
130 | 130 | */ |
131 | - public function valid_type( $type ) { |
|
132 | - return in_array( $type, $this->log_types() ); |
|
131 | + public function valid_type($type) { |
|
132 | + return in_array($type, $this->log_types()); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return int Log ID. |
150 | 150 | */ |
151 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
151 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
152 | 152 | $log_data = array( |
153 | 153 | 'post_title' => $title, |
154 | 154 | 'post_content' => $message, |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'log_type' => $type, |
157 | 157 | ); |
158 | 158 | |
159 | - return $this->insert_log( $log_data ); |
|
159 | + return $this->insert_log($log_data); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return array An array of the connected logs. |
175 | 175 | */ |
176 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
177 | - return $this->get_connected_logs( array( |
|
176 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
177 | + return $this->get_connected_logs(array( |
|
178 | 178 | 'post_parent' => $object_id, |
179 | 179 | 'paged' => $paged, |
180 | 180 | 'log_type' => $type, |
181 | - ) ); |
|
181 | + )); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return int The ID of the newly created log item. |
194 | 194 | */ |
195 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
195 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
196 | 196 | $defaults = array( |
197 | 197 | 'post_type' => 'give_log', |
198 | 198 | 'post_status' => 'publish', |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | 'log_type' => false, |
202 | 202 | ); |
203 | 203 | |
204 | - $args = wp_parse_args( $log_data, $defaults ); |
|
204 | + $args = wp_parse_args($log_data, $defaults); |
|
205 | 205 | |
206 | 206 | /** |
207 | 207 | * Fires before inserting log entry. |
@@ -211,20 +211,20 @@ discard block |
||
211 | 211 | * @param array $log_data Log entry data. |
212 | 212 | * @param array $log_meta Log entry meta. |
213 | 213 | */ |
214 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
214 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
215 | 215 | |
216 | 216 | // Store the log entry |
217 | - $log_id = wp_insert_post( $args ); |
|
217 | + $log_id = wp_insert_post($args); |
|
218 | 218 | |
219 | 219 | // Set the log type, if any |
220 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
221 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
220 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
221 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | // Set log meta, if any |
225 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
226 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
227 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
225 | + if ($log_id && ! empty($log_meta)) { |
|
226 | + foreach ((array) $log_meta as $key => $meta) { |
|
227 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param array $log_data Log entry data. |
238 | 238 | * @param array $log_meta Log entry meta. |
239 | 239 | */ |
240 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
240 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
241 | 241 | |
242 | 242 | return $log_id; |
243 | 243 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return bool|null True if successful, false otherwise. |
255 | 255 | */ |
256 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
256 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Fires before updating log entry. |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param array $log_data Log entry data. |
264 | 264 | * @param array $log_meta Log entry meta. |
265 | 265 | */ |
266 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
266 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
267 | 267 | |
268 | 268 | $defaults = array( |
269 | 269 | 'post_type' => 'give_log', |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | 'post_parent' => 0, |
272 | 272 | ); |
273 | 273 | |
274 | - $args = wp_parse_args( $log_data, $defaults ); |
|
274 | + $args = wp_parse_args($log_data, $defaults); |
|
275 | 275 | |
276 | 276 | // Store the log entry |
277 | - $log_id = wp_update_post( $args ); |
|
277 | + $log_id = wp_update_post($args); |
|
278 | 278 | |
279 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
280 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
281 | - if ( ! empty( $meta ) ) { |
|
282 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
279 | + if ($log_id && ! empty($log_meta)) { |
|
280 | + foreach ((array) $log_meta as $key => $meta) { |
|
281 | + if ( ! empty($meta)) { |
|
282 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param array $log_data Log entry data. |
294 | 294 | * @param array $log_meta Log entry meta. |
295 | 295 | */ |
296 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
296 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -308,19 +308,19 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return array|false Array if logs were found, false otherwise. |
310 | 310 | */ |
311 | - public function get_connected_logs( $args = array() ) { |
|
311 | + public function get_connected_logs($args = array()) { |
|
312 | 312 | |
313 | 313 | $defaults = array( |
314 | 314 | 'post_type' => 'give_log', |
315 | 315 | 'posts_per_page' => 20, |
316 | 316 | 'post_status' => 'publish', |
317 | - 'paged' => get_query_var( 'paged' ), |
|
317 | + 'paged' => get_query_var('paged'), |
|
318 | 318 | 'log_type' => false, |
319 | 319 | ); |
320 | 320 | |
321 | - $query_args = wp_parse_args( $args, $defaults ); |
|
321 | + $query_args = wp_parse_args($args, $defaults); |
|
322 | 322 | |
323 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
323 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
324 | 324 | $query_args['tax_query'] = array( |
325 | 325 | array( |
326 | 326 | 'taxonomy' => 'give_log_type', |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | ); |
331 | 331 | } |
332 | 332 | |
333 | - $logs = get_posts( $query_args ); |
|
333 | + $logs = get_posts($query_args); |
|
334 | 334 | |
335 | - if ( $logs ) { |
|
335 | + if ($logs) { |
|
336 | 336 | return $logs; |
337 | 337 | } |
338 | 338 | |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return int Log count. |
357 | 357 | */ |
358 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
358 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
359 | 359 | |
360 | 360 | $query_args = array( |
361 | 361 | 'post_parent' => $object_id, |
362 | 362 | 'post_type' => 'give_log', |
363 | - 'posts_per_page' => - 1, |
|
363 | + 'posts_per_page' => -1, |
|
364 | 364 | 'post_status' => 'publish', |
365 | 365 | 'fields' => 'ids', |
366 | 366 | ); |
367 | 367 | |
368 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
368 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
369 | 369 | $query_args['tax_query'] = array( |
370 | 370 | array( |
371 | 371 | 'taxonomy' => 'give_log_type', |
@@ -375,25 +375,25 @@ discard block |
||
375 | 375 | ); |
376 | 376 | } |
377 | 377 | |
378 | - if ( ! empty( $meta_query ) ) { |
|
378 | + if ( ! empty($meta_query)) { |
|
379 | 379 | $query_args['meta_query'] = $meta_query; |
380 | 380 | } |
381 | 381 | |
382 | - if ( ! empty( $date_query ) ) { |
|
382 | + if ( ! empty($date_query)) { |
|
383 | 383 | $query_args['date_query'] = $date_query; |
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | // Get cache key for current query. |
388 | - $cache_key = give_get_cache_key( 'get_log_count', $query_args ); |
|
388 | + $cache_key = give_get_cache_key('get_log_count', $query_args); |
|
389 | 389 | |
390 | 390 | // check if cache already exist or not. |
391 | - if( ! ( $logs_count = get_option( $cache_key ) ) ) { |
|
392 | - $logs = new WP_Query( $query_args ); |
|
391 | + if ( ! ($logs_count = get_option($cache_key))) { |
|
392 | + $logs = new WP_Query($query_args); |
|
393 | 393 | $logs_count = (int) $logs->post_count; |
394 | 394 | |
395 | 395 | // Cache results. |
396 | - add_option( $cache_key, $logs_count, '', 'no' ); |
|
396 | + add_option($cache_key, $logs_count, '', 'no'); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | return $logs_count; |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return void |
415 | 415 | */ |
416 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
416 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
417 | 417 | $query_args = array( |
418 | 418 | 'post_parent' => $object_id, |
419 | 419 | 'post_type' => 'give_log', |
420 | - 'posts_per_page' => - 1, |
|
420 | + 'posts_per_page' => -1, |
|
421 | 421 | 'post_status' => 'publish', |
422 | 422 | 'fields' => 'ids', |
423 | 423 | ); |
424 | 424 | |
425 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
425 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
426 | 426 | $query_args['tax_query'] = array( |
427 | 427 | array( |
428 | 428 | 'taxonomy' => 'give_log_type', |
@@ -432,15 +432,15 @@ discard block |
||
432 | 432 | ); |
433 | 433 | } |
434 | 434 | |
435 | - if ( ! empty( $meta_query ) ) { |
|
435 | + if ( ! empty($meta_query)) { |
|
436 | 436 | $query_args['meta_query'] = $meta_query; |
437 | 437 | } |
438 | 438 | |
439 | - $logs = get_posts( $query_args ); |
|
439 | + $logs = get_posts($query_args); |
|
440 | 440 | |
441 | - if ( $logs ) { |
|
442 | - foreach ( $logs as $log ) { |
|
443 | - wp_delete_post( $log, true ); |
|
441 | + if ($logs) { |
|
442 | + foreach ($logs as $log) { |
|
443 | + wp_delete_post($log, true); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @param int $post_id |
455 | 455 | */ |
456 | - public function background_process_delete_cache( $post_id ) { |
|
457 | - wp_schedule_single_event( time(), 'give_delete_log_cache' ); |
|
456 | + public function background_process_delete_cache($post_id) { |
|
457 | + wp_schedule_single_event(time(), 'give_delete_log_cache'); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | ); |
477 | 477 | |
478 | 478 | // Bailout. |
479 | - if( empty( $cache_option_names ) ) { |
|
479 | + if (empty($cache_option_names)) { |
|
480 | 480 | return false; |
481 | 481 | } |
482 | 482 | |
483 | 483 | |
484 | 484 | // Delete log cache. |
485 | - foreach ( $cache_option_names as $option_name ) { |
|
486 | - delete_option( $option_name['option_name'] ); |
|
485 | + foreach ($cache_option_names as $option_name) { |
|
486 | + delete_option($option_name['option_name']); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return int ID of the new log entry. |
508 | 508 | */ |
509 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
509 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
510 | 510 | /* @var Give_Logging $give_logs */ |
511 | 511 | global $give_logs; |
512 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
512 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
513 | 513 | |
514 | 514 | return $log; |
515 | 515 | } |
@@ -463,7 +463,7 @@ |
||
463 | 463 | * @since 1.7 |
464 | 464 | * @access public |
465 | 465 | * |
466 | - * @return bool |
|
466 | + * @return false|null |
|
467 | 467 | */ |
468 | 468 | public function delete_cache() { |
469 | 469 | global $wpdb; |
@@ -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 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function __construct() { |
97 | 97 | |
98 | 98 | // get it started |
99 | - add_action( 'init', array( $this, 'init' ) ); |
|
99 | + add_action('init', array($this, 'init')); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function init() { |
113 | 113 | |
114 | - $is_enabled = give_get_option( 'email_access' ); |
|
114 | + $is_enabled = give_get_option('email_access'); |
|
115 | 115 | |
116 | 116 | //Non-logged in users only |
117 | - if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) { |
|
117 | + if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | 121 | //Are db columns setup? |
122 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
123 | - if ( empty( $is_setup ) ) { |
|
122 | + $is_setup = give_get_option('email_access_installed'); |
|
123 | + if (empty($is_setup)) { |
|
124 | 124 | $this->create_columns(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Timeouts |
128 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
129 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
128 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
129 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
130 | 130 | |
131 | 131 | // Setup login |
132 | 132 | $this->check_for_token(); |
133 | 133 | |
134 | - if ( $this->token_exists ) { |
|
135 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
136 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
137 | - add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) ); |
|
134 | + if ($this->token_exists) { |
|
135 | + add_filter('give_can_view_receipt', '__return_true'); |
|
136 | + add_filter('give_user_pending_verification', '__return_false'); |
|
137 | + add_filter('give_get_users_donations_args', array($this, 'users_donations_args')); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -148,25 +148,25 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool |
150 | 150 | */ |
151 | - public function can_send_email( $customer_id ) { |
|
151 | + public function can_send_email($customer_id) { |
|
152 | 152 | /* @var WPDB $wpdb */ |
153 | 153 | global $wpdb; |
154 | 154 | |
155 | 155 | // Prevent multiple emails within X minutes |
156 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
156 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
157 | 157 | |
158 | 158 | // Does a user row exist? |
159 | 159 | $exists = (int) $wpdb->get_var( |
160 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
160 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
161 | 161 | ); |
162 | 162 | |
163 | - if ( 0 < $exists ) { |
|
163 | + if (0 < $exists) { |
|
164 | 164 | $row_id = (int) $wpdb->get_var( |
165 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
165 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
166 | 166 | ); |
167 | 167 | |
168 | - if ( $row_id < 1 ) { |
|
169 | - give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
168 | + if ($row_id < 1) { |
|
169 | + give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
170 | 170 | |
171 | 171 | return false; |
172 | 172 | } |
@@ -186,34 +186,34 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return void |
188 | 188 | */ |
189 | - public function send_email( $customer_id, $email ) { |
|
189 | + public function send_email($customer_id, $email) { |
|
190 | 190 | |
191 | - $verify_key = wp_generate_password( 20, false ); |
|
191 | + $verify_key = wp_generate_password(20, false); |
|
192 | 192 | |
193 | 193 | // Generate a new verify key |
194 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
194 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
195 | 195 | |
196 | 196 | // Get the donation history page |
197 | - $page_id = give_get_option( 'history_page' ); |
|
197 | + $page_id = give_get_option('history_page'); |
|
198 | 198 | |
199 | - $access_url = add_query_arg( array( |
|
199 | + $access_url = add_query_arg(array( |
|
200 | 200 | 'give_nl' => $verify_key, |
201 | - ), get_permalink( $page_id ) ); |
|
201 | + ), get_permalink($page_id)); |
|
202 | 202 | |
203 | 203 | //Nice subject and message |
204 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
204 | + $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
205 | 205 | |
206 | - $message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
207 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details »', 'give' ) . '</a>' . "\n\n"; |
|
206 | + $message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
207 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details »', 'give').'</a>'."\n\n"; |
|
208 | 208 | $message .= "\n\n"; |
209 | - $message .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
210 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
209 | + $message .= esc_html__('Sincerely,', 'give')."\n"; |
|
210 | + $message .= get_bloginfo('name')."\n"; |
|
211 | 211 | |
212 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
212 | + $message = apply_filters('give_email_access_token_message', $message); |
|
213 | 213 | |
214 | 214 | // Send the email |
215 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) ); |
|
216 | - Give()->emails->send( $email, $subject, $message ); |
|
215 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give'))); |
|
216 | + Give()->emails->send($email, $subject, $message); |
|
217 | 217 | |
218 | 218 | } |
219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function check_for_token() { |
229 | 229 | |
230 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
230 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
231 | 231 | |
232 | 232 | // Check for cookie |
233 | - if ( empty( $token ) ) { |
|
234 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
233 | + if (empty($token)) { |
|
234 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( ! empty( $token ) ) { |
|
238 | - if ( ! $this->is_valid_token( $token ) ) { |
|
239 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
237 | + if ( ! empty($token)) { |
|
238 | + if ( ! $this->is_valid_token($token)) { |
|
239 | + if ( ! $this->is_valid_verify_key($token)) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | 244 | $this->token_exists = true; |
245 | 245 | // Set cookie |
246 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
247 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
246 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
247 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -258,18 +258,18 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return bool |
260 | 260 | */ |
261 | - public function is_valid_token( $token ) { |
|
261 | + public function is_valid_token($token) { |
|
262 | 262 | |
263 | 263 | global $wpdb; |
264 | 264 | |
265 | 265 | // Make sure token isn't expired |
266 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
266 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
267 | 267 | |
268 | 268 | $email = $wpdb->get_var( |
269 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
269 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
270 | 270 | ); |
271 | 271 | |
272 | - if ( ! empty( $email ) ) { |
|
272 | + if ( ! empty($email)) { |
|
273 | 273 | $this->token_email = $email; |
274 | 274 | $this->token = $token; |
275 | 275 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | //Set error only if email access form isn't being submitted |
280 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
281 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', esc_html__( 'Your access token has expired. Please request a new one below:', 'give' ) ) ); |
|
280 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
281 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', esc_html__('Your access token has expired. Please request a new one below:', 'give'))); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return false; |
@@ -297,25 +297,25 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return void |
299 | 299 | */ |
300 | - public function set_verify_key( $customer_id, $email, $verify_key ) { |
|
300 | + public function set_verify_key($customer_id, $email, $verify_key) { |
|
301 | 301 | global $wpdb; |
302 | 302 | |
303 | - $now = date( 'Y-m-d H:i:s' ); |
|
303 | + $now = date('Y-m-d H:i:s'); |
|
304 | 304 | |
305 | 305 | // Insert or update? |
306 | 306 | $row_id = (int) $wpdb->get_var( |
307 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
307 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
308 | 308 | ); |
309 | 309 | |
310 | 310 | // Update |
311 | - if ( ! empty( $row_id ) ) { |
|
311 | + if ( ! empty($row_id)) { |
|
312 | 312 | $wpdb->query( |
313 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
313 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
314 | 314 | ); |
315 | 315 | } // Insert |
316 | 316 | else { |
317 | 317 | $wpdb->query( |
318 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
318 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | } |
@@ -330,21 +330,21 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return bool |
332 | 332 | */ |
333 | - public function is_valid_verify_key( $token ) { |
|
333 | + public function is_valid_verify_key($token) { |
|
334 | 334 | /* @var WPDB $wpdb */ |
335 | 335 | global $wpdb; |
336 | 336 | |
337 | 337 | // See if the verify_key exists |
338 | 338 | $row = $wpdb->get_row( |
339 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
339 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
340 | 340 | ); |
341 | 341 | |
342 | - $now = date( 'Y-m-d H:i:s' ); |
|
342 | + $now = date('Y-m-d H:i:s'); |
|
343 | 343 | |
344 | 344 | // Set token |
345 | - if ( ! empty( $row ) ) { |
|
345 | + if ( ! empty($row)) { |
|
346 | 346 | $wpdb->query( |
347 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
347 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
348 | 348 | ); |
349 | 349 | |
350 | 350 | $this->token_email = $row->email; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return mixed |
370 | 370 | */ |
371 | - public function users_donations_args( $args ) { |
|
371 | + public function users_donations_args($args) { |
|
372 | 372 | $args['user'] = $this->token_email; |
373 | 373 | |
374 | 374 | return $args; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | global $wpdb; |
390 | 390 | |
391 | 391 | //Create columns in customers table |
392 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
392 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
393 | 393 | |
394 | 394 | //Columns added properly |
395 | - if ( $query ) { |
|
396 | - give_update_option( 'email_access_installed', 1 ); |
|
395 | + if ($query) { |
|
396 | + give_update_option('email_access_installed', 1); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string $default_price |
69 | 69 | */ |
70 | -function give_get_default_multilevel_amount( $form_id ) { |
|
70 | +function give_get_default_multilevel_amount($form_id) { |
|
71 | 71 | $default_price = '1.00'; |
72 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
72 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
73 | 73 | |
74 | - foreach ( $prices as $price ) { |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | |
76 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
76 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
77 | 77 | $default_price = $price['_give_amount']; |
78 | 78 | } |
79 | 79 | |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | * @return string $default_price |
95 | 95 | * @since 1.0 |
96 | 96 | */ |
97 | -function give_get_default_form_amount( $form_id ) { |
|
97 | +function give_get_default_form_amount($form_id) { |
|
98 | 98 | |
99 | - if ( give_has_variable_prices( $form_id ) ) { |
|
99 | + if (give_has_variable_prices($form_id)) { |
|
100 | 100 | |
101 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
101 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
102 | 102 | |
103 | 103 | } else { |
104 | 104 | |
105 | - $default_amount = get_post_meta( $form_id, '_give_set_price', true ); |
|
105 | + $default_amount = get_post_meta($form_id, '_give_set_price', true); |
|
106 | 106 | |
107 | 107 | } |
108 | 108 | |
109 | - return apply_filters( 'give_default_form_amount', $default_amount ); |
|
109 | + return apply_filters('give_default_form_amount', $default_amount); |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool |
126 | 126 | */ |
127 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
127 | +function give_is_custom_price_mode($form_id = 0) { |
|
128 | 128 | |
129 | - if ( empty( $form_id ) ) { |
|
129 | + if (empty($form_id)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - $form = new Give_Donate_Form( $form_id ); |
|
133 | + $form = new Give_Donate_Form($form_id); |
|
134 | 134 | |
135 | 135 | return $form->is_custom_price_mode(); |
136 | 136 | } |
137 | 137 | \ 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,7 +35,7 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function add_roles() { |
52 | - add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array( |
|
52 | + add_role('give_manager', esc_html__('Give Manager', 'give'), array( |
|
53 | 53 | 'read' => true, |
54 | 54 | 'edit_posts' => true, |
55 | 55 | 'delete_posts' => true, |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | 'publish_posts' => true, |
79 | 79 | 'read_private_pages' => true, |
80 | 80 | 'read_private_posts' => true |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | - add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array( |
|
83 | + add_role('give_accountant', esc_html__('Give Accountant', 'give'), array( |
|
84 | 84 | 'read' => true, |
85 | 85 | 'edit_posts' => false, |
86 | 86 | 'delete_posts' => false |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | - add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array( |
|
89 | + add_role('give_worker', esc_html__('Give Worker', 'give'), array( |
|
90 | 90 | 'read' => true, |
91 | 91 | 'edit_posts' => false, |
92 | 92 | 'upload_files' => true, |
93 | 93 | 'delete_posts' => false |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -110,38 +110,38 @@ discard block |
||
110 | 110 | public function add_caps() { |
111 | 111 | global $wp_roles; |
112 | 112 | |
113 | - if ( class_exists( 'WP_Roles' ) ) { |
|
114 | - if ( ! isset( $wp_roles ) ) { |
|
113 | + if (class_exists('WP_Roles')) { |
|
114 | + if ( ! isset($wp_roles)) { |
|
115 | 115 | $wp_roles = new WP_Roles(); |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - if ( is_object( $wp_roles ) ) { |
|
120 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
121 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
122 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
123 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
119 | + if (is_object($wp_roles)) { |
|
120 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
121 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
122 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
123 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
124 | 124 | |
125 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
126 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
127 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
125 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
126 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
127 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
128 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
129 | 129 | |
130 | 130 | // Add the main post type capabilities. |
131 | 131 | $capabilities = $this->get_core_caps(); |
132 | - foreach ( $capabilities as $cap_group ) { |
|
133 | - foreach ( $cap_group as $cap ) { |
|
134 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
135 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
136 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
132 | + foreach ($capabilities as $cap_group) { |
|
133 | + foreach ($cap_group as $cap) { |
|
134 | + $wp_roles->add_cap('administrator', $cap); |
|
135 | + $wp_roles->add_cap('give_manager', $cap); |
|
136 | + $wp_roles->add_cap('give_worker', $cap); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
141 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
142 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
143 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
144 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
140 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
141 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
142 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
143 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
144 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | } |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | public function get_core_caps() { |
160 | 160 | $capabilities = array(); |
161 | 161 | |
162 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
162 | + $capability_types = array('give_form', 'give_payment'); |
|
163 | 163 | |
164 | - foreach ( $capability_types as $capability_type ) { |
|
165 | - $capabilities[ $capability_type ] = array( |
|
164 | + foreach ($capability_types as $capability_type) { |
|
165 | + $capabilities[$capability_type] = array( |
|
166 | 166 | // Post type. |
167 | 167 | "edit_{$capability_type}", |
168 | 168 | "read_{$capability_type}", |
@@ -208,22 +208,22 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return array $caps Meta capabilities. |
210 | 210 | */ |
211 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
211 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
212 | 212 | |
213 | - switch ( $cap ) { |
|
213 | + switch ($cap) { |
|
214 | 214 | |
215 | 215 | case 'view_give_form_stats' : |
216 | 216 | |
217 | - if ( empty( $args[0] ) ) { |
|
217 | + if (empty($args[0])) { |
|
218 | 218 | break; |
219 | 219 | } |
220 | 220 | |
221 | - $form = get_post( $args[0] ); |
|
222 | - if ( empty( $form ) ) { |
|
221 | + $form = get_post($args[0]); |
|
222 | + if (empty($form)) { |
|
223 | 223 | break; |
224 | 224 | } |
225 | 225 | |
226 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
226 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
227 | 227 | $caps = array(); |
228 | 228 | } |
229 | 229 | |
@@ -250,41 +250,41 @@ discard block |
||
250 | 250 | |
251 | 251 | global $wp_roles; |
252 | 252 | |
253 | - if ( class_exists( 'WP_Roles' ) ) { |
|
254 | - if ( ! isset( $wp_roles ) ) { |
|
253 | + if (class_exists('WP_Roles')) { |
|
254 | + if ( ! isset($wp_roles)) { |
|
255 | 255 | $wp_roles = new WP_Roles(); |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if ( is_object( $wp_roles ) ) { |
|
259 | + if (is_object($wp_roles)) { |
|
260 | 260 | // Give Manager Capabilities. |
261 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
262 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
263 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
264 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
261 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
262 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
263 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
264 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
265 | 265 | |
266 | 266 | // Site Administrator Capabilities. |
267 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
268 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
269 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
270 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
267 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
268 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
269 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
270 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
271 | 271 | |
272 | 272 | // Remove the Main Post Type Capabilities. |
273 | 273 | $capabilities = $this->get_core_caps(); |
274 | 274 | |
275 | - foreach ( $capabilities as $cap_group ) { |
|
276 | - foreach ( $cap_group as $cap ) { |
|
277 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
278 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
279 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
275 | + foreach ($capabilities as $cap_group) { |
|
276 | + foreach ($cap_group as $cap) { |
|
277 | + $wp_roles->remove_cap('give_manager', $cap); |
|
278 | + $wp_roles->remove_cap('administrator', $cap); |
|
279 | + $wp_roles->remove_cap('give_worker', $cap); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | 283 | /** Give Accountant Capabilities */ |
284 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
285 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
286 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
287 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
284 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
285 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
286 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
287 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
288 | 288 | |
289 | 289 | } |
290 | 290 | } |