PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.7.5
GiveWP – Donation Plugin and Fundraising Platform v2.7.5
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / tools / logs / class-gateway-error-logs-list-table.php
give / includes / admin / tools / logs Last commit date
class-api-requests-logs-list-table.php 6 years ago class-gateway-error-logs-list-table.php 6 years ago class-spam-logs-list-table.php 6 years ago class-update-logs-list-table.php 6 years ago logs.php 6 years ago
class-gateway-error-logs-list-table.php
278 lines
1 <?php
2 /**
3 * Gateway Error Log View Class.
4 *
5 * @package Give
6 * @subpackage Admin/Reports
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 */
10
11 // Exit if accessed directly.
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 // Load WP_List_Table if not loaded.
17 if ( ! class_exists( 'WP_List_Table' ) ) {
18 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
19 }
20
21 /**
22 * Give_Gateway_Error_Log_Table Class.
23 *
24 * Renders the gateway errors list table.
25 *
26 * @access private
27 * @since 1.0
28 */
29 class Give_Gateway_Error_Log_Table extends WP_List_Table {
30
31 /**
32 * Number of items per page.
33 *
34 * @var int
35 * @since 1.0
36 */
37 public $per_page = 30;
38
39 /**
40 * Get things started.
41 *
42 * @since 1.0
43 * @see WP_List_Table::__construct()
44 */
45 public function __construct() {
46 // Set parent defaults.
47 parent::__construct(
48 array(
49 'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
50 'plural' => give_get_forms_label_plural(), // Plural name of the listed records.
51 'ajax' => false, // Does this table support ajax?.
52 )
53 );
54 }
55
56 /**
57 * This function renders most of the columns in the list table.
58 *
59 * @access public
60 * @since 1.0
61 *
62 * @param array $item Contains all the data of the log item.
63 * @param string $column_name The name of the column.
64 *
65 * @return string Column Name.
66 */
67 public function column_default( $item, $column_name ) {
68
69 switch ( $column_name ) {
70 case 'ID':
71 return $item['ID_label'];
72 case 'payment_id':
73 return empty( $item['payment_id'] ) ? esc_html__( 'n/a', 'give' ) : sprintf( "<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link( $item['payment_id'] ) );
74 case 'gateway':
75 return empty( $item['gateway'] ) ? esc_html__( 'n/a', 'give' ) : $item['gateway'];
76 case 'error':
77 return esc_html( $item['log_title'] );
78 default:
79 return $item[ $column_name ];
80 }
81 }
82
83 /**
84 * Output Error Message Column.
85 *
86 * @access public
87 * @since 1.0
88 *
89 * @param array $item Contains all the data of the log.
90 *
91 * @return void
92 */
93 public function column_message( $item ) {
94 ?>
95 <?php
96 echo Give()->tooltips->render_link(
97 array(
98 'label' => __( 'View Log Message', 'give' ),
99 'tag_content' => '<span class="dashicons dashicons-visibility"></span>',
100 'link' => "#TB_inline?width=640&amp;inlineId=log-message-{$item['ID']}",
101 'attributes' => array(
102 'class' => 'thickbox give-error-log-details-link button button-small',
103 ),
104 )
105 );
106 ?>
107 <div id="log-message-<?php echo $item['ID']; ?>" style="display:none;">
108 <?php
109
110 $serialized = strpos( $item['log_content'], '{"' );
111
112 // Check to see if the log message contains serialized information
113 if ( $serialized !== false ) {
114 $length = strlen( $item['log_content'] ) - $serialized;
115 $intro = substr( $item['log_content'], 0, - $length );
116 $data = substr( $item['log_content'], $serialized, strlen( $item['log_content'] ) - 1 );
117
118 echo wpautop( $intro );
119 echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' );
120 echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>';
121 } else {
122 // No serialized data found
123 echo wpautop( $item['log_content'] );
124 }
125 ?>
126 </div>
127 <?php
128 }
129
130 /**
131 * Retrieve the table columns.
132 *
133 * @access public
134 * @since 1.0
135 * @return array $columns Array of all the list table columns.
136 */
137 public function get_columns() {
138 $columns = array(
139 'ID' => esc_html__( 'Log ID', 'give' ),
140 'error' => esc_html__( 'Error', 'give' ),
141 'gateway' => esc_html__( 'Gateway', 'give' ),
142 'payment_id' => esc_html__( 'Donation ID', 'give' ),
143 'date' => esc_html__( 'Date', 'give' ),
144 'message' => esc_html__( 'Details', 'give' ),
145 );
146
147 return $columns;
148 }
149
150 /**
151 * Retrieve the current page number
152 *
153 * @access public
154 * @since 1.0
155 * @return int Current page number
156 */
157 public function get_paged() {
158 return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
159 }
160
161 /**
162 * Outputs the log views
163 *
164 * @access public
165 * @since 1.0
166 * @return void
167 */
168 public function bulk_actions( $which = '' ) {
169 give_log_views();
170 }
171
172 /**
173 * Gets the log entries for the current view.
174 *
175 * @access public
176 * @since 1.0
177 *
178 * @return array $logs_data Array of all the Log entries.
179 */
180 public function get_logs() {
181 // Prevent the queries from getting cached.
182 // Without this there are occasional memory issues for some installs.
183 wp_suspend_cache_addition( true );
184
185 $logs_data = array();
186 $paged = $this->get_paged();
187 $log_query = array(
188 'log_type' => 'gateway_error',
189 'paged' => $paged,
190 'posts_per_page' => $this->per_page,
191 );
192
193 $logs = Give()->logs->get_connected_logs( $log_query );
194
195 if ( $logs ) {
196 foreach ( $logs as $log ) {
197
198 $logs_data[] = array(
199 'ID' => $log->ID,
200 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>',
201 'payment_id' => $log->log_parent,
202 'error' => 'error',
203 'gateway' => give_get_payment_gateway( $log->log_parent ),
204 'date' => $log->log_date,
205 'log_content' => $log->log_content,
206 'log_title' => $log->log_title,
207 );
208 }
209 }
210
211 return $logs_data;
212 }
213
214 /**
215 * Display Tablenav (extended).
216 *
217 * Display the table navigation above or below the table even when no items in the logs,
218 * so nav doesn't disappear.
219 *
220 * @see : https://github.com/impress-org/give/issues/564
221 *
222 * @since 1.4.1
223 * @access protected
224 *
225 * @param string $which
226 */
227 protected function display_tablenav( $which ) {
228 if ( 'top' === $which ) {
229 wp_nonce_field( 'bulk-' . $this->_args['plural'] );
230 }
231 ?>
232 <div class="tablenav <?php echo esc_attr( $which ); ?>">
233
234 <div class="alignleft actions bulkactions">
235 <?php $this->bulk_actions( $which ); ?>
236 </div>
237 <?php
238 $this->extra_tablenav( $which );
239 $this->pagination( $which );
240 ?>
241
242 <br class="clear"/>
243 </div>
244 <?php
245 }
246
247 /**
248 * Setup the final data for the table
249 *
250 * @access public
251 * @since 1.0
252 *
253 * @uses Give_Gateway_Error_Log_Table::get_columns()
254 * @uses WP_List_Table::get_sortable_columns()
255 * @uses Give_Gateway_Error_Log_Table::get_pagenum()
256 * @uses Give_Gateway_Error_Log_Table::get_logs()
257 * @uses Give_Gateway_Error_Log_Table::get_log_count()
258 * @return void
259 */
260 public function prepare_items() {
261
262 $columns = $this->get_columns();
263 $hidden = array(); // No hidden columns
264 $sortable = $this->get_sortable_columns();
265 $this->_column_headers = array( $columns, $hidden, $sortable );
266 $this->items = $this->get_logs();
267 $total_items = Give()->logs->get_log_count( 0, 'gateway_error' );
268
269 $this->set_pagination_args(
270 array(
271 'total_items' => $total_items,
272 'per_page' => $this->per_page,
273 'total_pages' => ceil( $total_items / $this->per_page ),
274 )
275 );
276 }
277 }
278