Completed
Push — hotfix/give_currency_filter ( 2ab3ef )
by Ravinder
49:07 queued 29:09
created

logs.php ➔ give_log_views()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 28
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 0
dl 0
loc 28
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
	$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::search_box()
84
 * @uses  Give_API_Request_Log_Table::display()
85
 * @return void
86
 */
87
function give_logs_view_api_requests() {
88
	include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-api-requests-logs-list-table.php' );
89
90
	$logs_table = new Give_API_Request_Log_Table();
91
	$logs_table->prepare_items();
92
	?>
93
	<div class="wrap">
94
95
		<?php
96
		/**
97
		 * Fires before displaying API requests logs.
98
		 *
99
		 * @since 1.0
100
		 */
101
		do_action( 'give_logs_api_requests_top' );
102
		?>
103
104
		<form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs'; ?>">
105
			<?php
106
			$logs_table->search_box( esc_html__( 'Search', 'give' ), 'give-api-requests' );
107
			$logs_table->display();
108
			?>
109
			<input type="hidden" name="post_type" value="give_forms"/>
110
			<input type="hidden" name="page" value="give-tools"/>
111
			<input type="hidden" name="tab" value="logs"/>
112
		</form>
113
		<?php
114
		/**
115
		 * Fires after displaying API requests logs.
116
		 *
117
		 * @since 1.0
118
		 */
119
		do_action( 'give_logs_api_requests_bottom' );
120
		?>
121
122
	</div>
123
	<?php
124
}
125
126
add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' );
127
128
/**
129
 * Renders the log views drop down.
130
 *
131
 * @since 1.0
132
 * @return void
133
 */
134
function give_log_views() {
135
	$current_section = give_get_current_setting_section();
136
137
	// If there are not any event attach to action then do not show form.
138
	if ( ! has_action( 'give_log_view_actions' ) ) {
139
		return;
140
	}
141
	?>
142
	<form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs&section=' . $current_section; ?>">
143
		<?php
144
		/**
145
		 * Fires after displaying the reports page views drop down.
146
		 *
147
		 * Allows you to add view actions.
148
		 *
149
		 * @since 1.0
150
		 */
151
		do_action( 'give_log_view_actions' );
152
		?>
153
154
		<input type="hidden" name="post_type" value="give_forms"/>
155
		<input type="hidden" name="page" value="give-tools"/>
156
		<input type="hidden" name="tab" value="logs"/>
157
158
		<?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?>
159
	</form>
160
	<?php
161
}