|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Give Reports Page/Tab |
|
4
|
|
|
* |
|
5
|
|
|
* @package Give |
|
6
|
|
|
* @subpackage Classes/Give_Forms_Report |
|
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
|
|
|
if ( ! class_exists( 'Give_Forms_Report' ) ) : |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Give_Forms_Report. |
|
20
|
|
|
* |
|
21
|
|
|
* @sine 1.8 |
|
22
|
|
|
*/ |
|
23
|
|
|
class Give_Forms_Report { |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Setting page id. |
|
27
|
|
|
* |
|
28
|
|
|
* @since 1.8 |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $id = ''; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Setting page label. |
|
35
|
|
|
* |
|
36
|
|
|
* @since 1.8 |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $label = ''; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Constructor. |
|
43
|
|
|
*/ |
|
44
|
|
|
public function __construct() { |
|
45
|
|
|
$this->id = 'forms'; |
|
46
|
|
|
$this->label = esc_html__( 'Forms', 'give' ); |
|
47
|
|
|
|
|
48
|
|
|
add_filter( 'give-reports_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49
|
|
|
add_action( "give-reports_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
50
|
|
|
add_action( 'give_admin_field_report_forms', array( $this, 'render_report_forms_field' ), 10, 2 ); |
|
51
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Add this page to settings. |
|
56
|
|
|
* |
|
57
|
|
|
* @since 1.8 |
|
58
|
|
|
* @param array $pages List of pages. |
|
59
|
|
|
* @return array |
|
60
|
|
|
*/ |
|
61
|
|
|
public function add_settings_page( $pages ) { |
|
62
|
|
|
$pages[ $this->id ] = $this->label; |
|
63
|
|
|
|
|
64
|
|
|
return $pages; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Get settings array. |
|
69
|
|
|
* |
|
70
|
|
|
* @since 1.8 |
|
71
|
|
|
* @return array |
|
72
|
|
|
*/ |
|
73
|
|
|
public function get_settings() { |
|
74
|
|
|
// Hide save button. |
|
75
|
|
|
$GLOBALS['give_hide_save_button'] = true; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Filter the settings. |
|
79
|
|
|
* |
|
80
|
|
|
* @since 1.8 |
|
81
|
|
|
* @param array $settings |
|
82
|
|
|
*/ |
|
83
|
|
|
$settings = apply_filters( |
|
84
|
|
|
'give_get_settings_' . $this->id, |
|
85
|
|
|
array( |
|
86
|
|
|
array( |
|
87
|
|
|
'id' => 'give_reports_forms', |
|
88
|
|
|
'type' => 'title', |
|
89
|
|
|
'table_html' => false |
|
|
|
|
|
|
90
|
|
|
), |
|
91
|
|
|
array( |
|
92
|
|
|
'id' => 'forms', |
|
93
|
|
|
'name' => esc_html__( 'Forms', 'give' ), |
|
94
|
|
|
'type' => 'report_forms', |
|
95
|
|
|
), |
|
96
|
|
|
array( |
|
97
|
|
|
'id' => 'give_reports_forms', |
|
98
|
|
|
'type' => 'sectionend', |
|
99
|
|
|
'table_html' => false |
|
|
|
|
|
|
100
|
|
|
) |
|
|
|
|
|
|
101
|
|
|
) |
|
102
|
|
|
); |
|
103
|
|
|
|
|
104
|
|
|
// Output. |
|
105
|
|
|
return $settings; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Output the settings. |
|
110
|
|
|
* |
|
111
|
|
|
* @since 1.8 |
|
112
|
|
|
* @return void |
|
113
|
|
|
*/ |
|
114
|
|
|
public function output() { |
|
115
|
|
|
$settings = $this->get_settings(); |
|
116
|
|
|
|
|
117
|
|
|
Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Render report forms field |
|
122
|
|
|
* |
|
123
|
|
|
* @since 1.8 |
|
124
|
|
|
* @access public |
|
125
|
|
|
* |
|
126
|
|
|
* @param $field |
|
127
|
|
|
* @param $option_value |
|
128
|
|
|
*/ |
|
129
|
|
|
public function render_report_forms_field( $field, $option_value ) { |
|
|
|
|
|
|
130
|
|
|
do_action( 'give_reports_view_forms'); |
|
|
|
|
|
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
endif; |
|
135
|
|
|
|
|
136
|
|
|
return new Give_Forms_Report(); |
|
137
|
|
|
|