Completed
Pull Request — master (#1907)
by
unknown
19:56
created

logs.php ➔ give_logs_view_gateway_errors()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 0
dl 0
loc 34
rs 8.8571
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 23 and the first side effect is on line 14.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Logs UI
4
 *
5
 * @package     Give
6
 * @subpackage  Admin/Reports
7
 * @copyright   Copyright (c) 2016, WordImpress
8
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
9
 * @since       1.0
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Renders the logs tab.
19
 *
20
 * @since 1.0
21
 * @return void
22
 */
23
function give_get_logs_tab() {
24
25
	require( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php' );
26
27
	// Get current section.
28
	$current_section = $_GET['section'] = give_get_current_setting_section();
29
30
	/**
31
	 * Fires the in report page logs view.
32
	 *
33
	 * @since 1.0
34
	 */
35
	do_action( "give_logs_view_{$current_section}" );
36
}
37
38
39
/**
40
 * Sales Log View
41
 *
42
 * @since 1.0
43
 * @uses  Give_Sales_Log_Table::prepare_items()
44
 * @uses  Give_Sales_Log_Table::display()
45
 * @return void
46
 */
47
function give_logs_view_sales() {
48
49
	include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-sales-logs-list-table.php';
50
51
	$logs_table = new Give_Sales_Log_Table();
52
	$logs_table->prepare_items();
53
	?>
54
	<div class="wrap">
55
56
		<?php
57
		/**
58
		 * Fires before displaying Donations logs.
59
		 *
60
		 * @since 1.8.12
61
		 */
62
		do_action( 'give_logs_donations_top' );
63
64
		$logs_table->display(); ?>
65
		<input type="hidden" name="post_type" value="give_forms"/>
66
		<input type="hidden" name="page" value="give-tools"/>
67
		<input type="hidden" name="tab" value="logs"/>
68
		<input type="hidden" name="section" value="sales"/>
69
70
		<?php
71
		/**
72
		 * Fires after displaying Donations logs.
73
		 *
74
		 * @since 1.8.12
75
		 */
76
		do_action( 'give_logs_donations_bottom' );
77
		?>
78
79
	</div>
80
	<?php
81
}
82
83
add_action( 'give_logs_view_sales', 'give_logs_view_sales' );
84
85
86
/**
87
 * Gateway Error Logs
88
 *
89
 * @since 1.0
90
 * @uses  Give_File_Downloads_Log_Table::prepare_items()
91
 * @uses  Give_File_Downloads_Log_Table::display()
92
 * @return void
93
 */
94
function give_logs_view_gateway_errors() {
95
	include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-gateway-error-logs-list-table.php' );
96
97
	$logs_table = new Give_Gateway_Error_Log_Table();
98
	$logs_table->prepare_items();
99
	?>
100
	<div class="wrap">
101
102
		<?php
103
		/**
104
		 * Fires before displaying Payment Error logs.
105
		 *
106
		 * @since 1.8.12
107
		 */
108
		do_action( 'give_logs_payment_error_top' );
109
110
		$logs_table->display(); ?>
111
		<input type="hidden" name="post_type" value="give_forms"/>
112
		<input type="hidden" name="page" value="give-tools"/>
113
		<input type="hidden" name="tab" value="logs"/>
114
		<input type="hidden" name="section" value="gateway_errors"/>
115
116
		<?php
117
		/**
118
		 * Fires after displaying Payment Error logs.
119
		 *
120
		 * @since 1.8.12
121
		 */
122
		do_action( 'give_logs_payment_error_bottom' );
123
		?>
124
125
	</div>
126
	<?php
127
}
128
129
add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' );
130
131
/**
132
 * API Request Logs
133
 *
134
 * @since 1.0
135
 * @uses  Give_API_Request_Log_Table::prepare_items()
136
 * @uses  Give_API_Request_Log_Table::search_box()
137
 * @uses  Give_API_Request_Log_Table::display()
138
 * @return void
139
 */
140
function give_logs_view_api_requests() {
141
	include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-api-requests-logs-list-table.php' );
142
143
	$logs_table = new Give_API_Request_Log_Table();
144
	$logs_table->prepare_items();
145
	?>
146
	<div class="wrap">
147
148
		<?php
149
		/**
150
		 * Fires before displaying API requests logs.
151
		 *
152
		 * @since 1.0
153
		 */
154
		do_action( 'give_logs_api_requests_top' );
155
156
		$logs_table->search_box( esc_html__( 'Search', 'give' ), 'give-api-requests' );
157
		$logs_table->display();
158
		?>
159
		<input type="hidden" name="post_type" value="give_forms"/>
160
		<input type="hidden" name="page" value="give-tools"/>
161
		<input type="hidden" name="tab" value="logs"/>
162
		<input type="hidden" name="section" value="api_requests"/>
163
164
		<?php
165
		/**
166
		 * Fires after displaying API requests logs.
167
		 *
168
		 * @since 1.0
169
		 */
170
		do_action( 'give_logs_api_requests_bottom' );
171
		?>
172
173
	</div>
174
	<?php
175
}
176
177
add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' );
178
179
/**
180
 * Renders the log views drop down.
181
 *
182
 * @since 1.0
183
 * @return void
184
 */
185
function give_log_views() {
186
	$current_section = give_get_current_setting_section();
187
188
	// If there are not any event attach to action then do not show form.
189
	if ( ! has_action( 'give_log_view_actions' ) ) {
190
		return;
191
	}
192
	?>
193
	<form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs&section=' . $current_section; ?>">
194
		<?php
195
		/**
196
		 * Fires after displaying the reports page views drop down.
197
		 *
198
		 * Allows you to add view actions.
199
		 *
200
		 * @since 1.0
201
		 */
202
		do_action( 'give_log_view_actions' );
203
		?>
204
205
		<input type="hidden" name="post_type" value="give_forms"/>
206
		<input type="hidden" name="page" value="give-tools"/>
207
		<input type="hidden" name="tab" value="logs"/>
208
209
		<?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?>
210
	</form>
211
	<?php
212
}
213
214
/**
215
 * Set Get form method for tools page
216
 *
217
 * @since 1.8.12
218
 *
219
 * @return string
220
 */
221
function give_tools_set_form_method( $method ) {
0 ignored issues
show
Unused Code introduced by
The parameter $method is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
222
	return 'get';
223
}
224
add_filter( 'give-tools_form_method_tab_logs', 'give_tools_set_form_method', 10 );
225