1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Give Exports Tab |
4
|
|
|
* |
5
|
|
|
* @package Give |
6
|
|
|
* @subpackage Classes/Give_Settings_Export |
7
|
|
|
* @copyright Copyright (c) 2016, WordImpress |
8
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
9
|
|
|
* @since 1.8 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
13
|
|
|
exit; // Exit if accessed directly |
14
|
|
|
} |
15
|
|
|
|
16
|
|
View Code Duplication |
if ( ! class_exists( 'Give_Settings_Export' ) ) : |
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Give_Settings_Export. |
20
|
|
|
* |
21
|
|
|
* @sine 1.8 |
22
|
|
|
*/ |
23
|
|
|
class Give_Settings_Export extends Give_Settings_Page { |
24
|
|
|
/** |
25
|
|
|
* Flag to check if enable saving option for setting page or not |
26
|
|
|
* |
27
|
|
|
* @since 1.8.17 |
28
|
|
|
* @var bool |
29
|
|
|
*/ |
30
|
|
|
protected $enable_save = false; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Constructor. |
34
|
|
|
*/ |
35
|
|
|
public function __construct() { |
36
|
|
|
$this->id = 'export'; |
37
|
|
|
$this->label = __( 'Export', 'give' ); |
38
|
|
|
|
39
|
|
|
parent::__construct(); |
40
|
|
|
|
41
|
|
|
add_action( 'give_admin_field_tools_export', array( $this, 'render_export_field' ), 10, 2 ); |
42
|
|
|
|
43
|
|
|
// Do not use main donor for this tab. |
44
|
|
|
if( give_get_current_setting_tab() === $this->id ) { |
|
|
|
|
45
|
|
|
add_action( 'give-tools_open_form', '__return_empty_string' ); |
46
|
|
|
add_action( 'give-tools_close_form', '__return_empty_string' ); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get settings array. |
52
|
|
|
* |
53
|
|
|
* @since 1.8 |
54
|
|
|
* @return array |
55
|
|
|
*/ |
56
|
|
|
public function get_settings() { |
57
|
|
|
/** |
58
|
|
|
* Filter the settings. |
59
|
|
|
* |
60
|
|
|
* @since 1.8 |
61
|
|
|
* @param array $settings |
62
|
|
|
*/ |
63
|
|
|
$settings = apply_filters( |
64
|
|
|
'give_get_settings_' . $this->id, |
65
|
|
|
array( |
66
|
|
|
array( |
67
|
|
|
'id' => 'give_tools_export', |
68
|
|
|
'type' => 'title', |
69
|
|
|
'table_html' => false |
|
|
|
|
70
|
|
|
), |
71
|
|
|
array( |
72
|
|
|
'id' => 'export', |
73
|
|
|
'name' => __( 'Export', 'give' ), |
74
|
|
|
'type' => 'tools_export', |
75
|
|
|
), |
76
|
|
|
array( |
77
|
|
|
'id' => 'give_tools_export', |
78
|
|
|
'type' => 'sectionend', |
79
|
|
|
'table_html' => false |
|
|
|
|
80
|
|
|
) |
|
|
|
|
81
|
|
|
) |
82
|
|
|
); |
83
|
|
|
|
84
|
|
|
// Output. |
85
|
|
|
return $settings; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Render report export field |
90
|
|
|
* |
91
|
|
|
* @since 1.8 |
92
|
|
|
* @access public |
93
|
|
|
* |
94
|
|
|
* @param $field |
95
|
|
|
* @param $option_value |
96
|
|
|
*/ |
97
|
|
|
public function render_export_field( $field, $option_value ) { |
98
|
|
|
include_once( 'views/html-admin-page-exports.php' ); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
endif; |
103
|
|
|
|
104
|
|
|
return new Give_Settings_Export(); |
105
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.