PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.2.1
GiveWP – Donation Plugin and Fundraising Platform v2.2.1
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 8 years ago class-gateway-error-logs-list-table.php 8 years ago class-sales-logs-list-table.php 7 years ago class-update-logs-list-table.php 8 years ago logs.php 8 years ago
class-gateway-error-logs-list-table.php
273 lines
1 <?php
2 /**
3 * Gateway Error Log View Class.
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 */
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( array(
48 'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
49 'plural' => give_get_forms_label_plural(), // Plural name of the listed records.
50 'ajax' => false,// Does this table support ajax?.
51 ) );
52 }
53
54 /**
55 * This function renders most of the columns in the list table.
56 *
57 * @access public
58 * @since 1.0
59 *
60 * @param array $item Contains all the data of the log item.
61 * @param string $column_name The name of the column.
62 *
63 * @return string Column Name.
64 */
65 public function column_default( $item, $column_name ) {
66
67 switch ( $column_name ) {
68 case 'ID' :
69 return $item['ID_label'];
70 case 'payment_id' :
71 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'] ) );
72 case 'gateway' :
73 return empty( $item['gateway'] ) ? esc_html__( 'n/a', 'give' ) : $item['gateway'];
74 case 'error' :
75 return esc_html( $item['log_title'] );
76 default:
77 return $item[ $column_name ];
78 }
79 }
80
81 /**
82 * Output Error Message Column.
83 *
84 * @access public
85 * @since 1.0
86 *
87 * @param array $item Contains all the data of the log.
88 *
89 * @return void
90 */
91 public function column_message( $item ) {
92 ?>
93 <?php
94 echo Give()->tooltips->render_link( array(
95 'label' => __( 'View Log Message', 'give' ),
96 'tag_content' => '<span class="dashicons dashicons-visibility"></span>',
97 'link' => "#TB_inline?width=640&amp;inlineId=log-message-{$item['ID']}",
98 'attributes' => array(
99 'class' => 'thickbox give-error-log-details-link button button-small',
100 ),
101 ) );
102 ?>
103 <div id="log-message-<?php echo $item['ID']; ?>" style="display:none;">
104 <?php
105
106 $serialized = strpos( $item['log_content'], '{"' );
107
108 // Check to see if the log message contains serialized information
109 if ( $serialized !== false ) {
110 $length = strlen( $item['log_content'] ) - $serialized;
111 $intro = substr( $item['log_content'], 0, - $length );
112 $data = substr( $item['log_content'], $serialized, strlen( $item['log_content'] ) - 1 );
113
114 echo wpautop( $intro );
115 echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' );
116 echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>';
117 } else {
118 // No serialized data found
119 echo wpautop( $item['log_content'] );
120 }
121 ?>
122 </div>
123 <?php
124 }
125
126 /**
127 * Retrieve the table columns.
128 *
129 * @access public
130 * @since 1.0
131 * @return array $columns Array of all the list table columns.
132 */
133 public function get_columns() {
134 $columns = array(
135 'ID' => esc_html__( 'Log ID', 'give' ),
136 'error' => esc_html__( 'Error', 'give' ),
137 'gateway' => esc_html__( 'Gateway', 'give' ),
138 'payment_id' => esc_html__( 'Donation ID', 'give' ),
139 'date' => esc_html__( 'Date', 'give' ),
140 'message' => esc_html__( 'Details', 'give' ),
141 );
142
143 return $columns;
144 }
145
146 /**
147 * Retrieve the current page number
148 *
149 * @access public
150 * @since 1.0
151 * @return int Current page number
152 */
153 public function get_paged() {
154 return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
155 }
156
157 /**
158 * Outputs the log views
159 *
160 * @access public
161 * @since 1.0
162 * @return void
163 */
164 public function bulk_actions( $which = '' ) {
165 give_log_views();
166 }
167
168 /**
169 * Gets the log entries for the current view.
170 *
171 * @access public
172 * @since 1.0
173 *
174 * @return array $logs_data Array of all the Log entries.
175 */
176 public function get_logs() {
177 // Prevent the queries from getting cached.
178 // Without this there are occasional memory issues for some installs.
179 wp_suspend_cache_addition( true );
180
181 $logs_data = array();
182 $paged = $this->get_paged();
183 $log_query = array(
184 'log_type' => 'gateway_error',
185 'paged' => $paged,
186 'posts_per_page' => $this->per_page,
187 );
188
189 $logs = Give()->logs->get_connected_logs( $log_query );
190
191 if ( $logs ) {
192 foreach ( $logs as $log ) {
193
194 $logs_data[] = array(
195 'ID' => $log->ID,
196 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>',
197 'payment_id' => $log->log_parent,
198 'error' => 'error',
199 'gateway' => give_get_payment_gateway( $log->log_parent ),
200 'date' => $log->log_date,
201 'log_content' => $log->log_content,
202 'log_title' => $log->log_title,
203 );
204 }
205 }
206
207 return $logs_data;
208 }
209
210 /**
211 * Display Tablenav (extended).
212 *
213 * Display the table navigation above or below the table even when no items in the logs,
214 * so nav doesn't disappear.
215 *
216 * @see : https://github.com/WordImpress/Give/issues/564
217 *
218 * @since 1.4.1
219 * @access protected
220 *
221 * @param string $which
222 */
223 protected function display_tablenav( $which ) {
224 if ( 'top' === $which ) {
225 wp_nonce_field( 'bulk-' . $this->_args['plural'] );
226 }
227 ?>
228 <div class="tablenav <?php echo esc_attr( $which ); ?>">
229
230 <div class="alignleft actions bulkactions">
231 <?php $this->bulk_actions( $which ); ?>
232 </div>
233 <?php
234 $this->extra_tablenav( $which );
235 $this->pagination( $which );
236 ?>
237
238 <br class="clear"/>
239 </div>
240 <?php
241 }
242
243 /**
244 * Setup the final data for the table
245 *
246 * @access public
247 * @since 1.0
248 *
249 * @uses Give_Gateway_Error_Log_Table::get_columns()
250 * @uses WP_List_Table::get_sortable_columns()
251 * @uses Give_Gateway_Error_Log_Table::get_pagenum()
252 * @uses Give_Gateway_Error_Log_Table::get_logs()
253 * @uses Give_Gateway_Error_Log_Table::get_log_count()
254 * @return void
255 */
256 public function prepare_items() {
257
258 $columns = $this->get_columns();
259 $hidden = array(); // No hidden columns
260 $sortable = $this->get_sortable_columns();
261 $this->_column_headers = array( $columns, $hidden, $sortable );
262 $this->items = $this->get_logs();
263 $total_items = Give()->logs->get_log_count( 0, 'gateway_error' );
264
265 $this->set_pagination_args( array(
266 'total_items' => $total_items,
267 'per_page' => $this->per_page,
268 'total_pages' => ceil( $total_items / $this->per_page ),
269 )
270 );
271 }
272 }
273