Completed
Push — issues/1132 ( b0ddd9...34d612 )
by Ravinder
22:33 queued 02:37
created

logs.php ➔ give_logs_view_api_requests()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 23
rs 9.0856
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
	$logs_table->display();
54
55
}
56
57
add_action( 'give_logs_view_sales', 'give_logs_view_sales' );
58
59
60
/**
61
 * Gateway Error Logs
62
 *
63
 * @since 1.0
64
 * @uses  Give_File_Downloads_Log_Table::prepare_items()
65
 * @uses  Give_File_Downloads_Log_Table::display()
66
 * @return void
67
 */
68
function give_logs_view_gateway_errors() {
69
	include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-gateway-error-logs-list-table.php' );
70
71
	$logs_table = new Give_Gateway_Error_Log_Table();
72
	$logs_table->prepare_items();
73
	$logs_table->display();
74
}
75
76
add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' );
77
78
/**
79
 * API Request Logs
80
 *
81
 * @since 1.0
82
 * @uses  Give_API_Request_Log_Table::prepare_items()
83
 * @uses  Give_API_Request_Log_Table::display()
84
 * @return void
85
 */
86
function give_logs_view_api_requests() {
87
	include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-api-requests-logs-list-table.php' );
88
89
	$logs_table = new Give_API_Request_Log_Table();
90
	$logs_table->prepare_items();
91
92
	/**
93
	 * Fires before displaying API requests logs.
94
	 *
95
	 * @since 1.0
96
	 */
97
	do_action( 'give_logs_api_requests_top' );
98
99
	$logs_table->display();
100
101
	/**
102
	 * Fires after displaying API requests logs.
103
	 *
104
	 * @since 1.0
105
	 */
106
	do_action( 'give_logs_api_requests_bottom' );
107
108
}
109
110
add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' );
111
112
/**
113
 * Renders the log views drop down.
114
 *
115
 * @since 1.0
116
 * @return void
117
 */
118
function give_log_views() {
119
	$current_section = give_get_current_setting_section();
120
121
	// If there are not any event attach to action then do not show form.
122
	if ( ! has_action( 'give_log_view_actions' ) ) {
123
		return;
124
	}
125
	?>
126
	<form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs&section=' . $current_section; ?>">
127
		<?php
128
		/**
129
		 * Fires after displaying the reports page views drop down.
130
		 *
131
		 * Allows you to add view actions.
132
		 *
133
		 * @since 1.0
134
		 */
135
		do_action( 'give_log_view_actions' );
136
		?>
137
138
		<input type="hidden" name="post_type" value="give_forms"/>
139
		<input type="hidden" name="page" value="give-tools"/>
140
		<input type="hidden" name="tab" value="logs"/>
141
142
		<?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?>
143
	</form>
144
	<?php
145
}