PluginProbe
Leaky Paywall / trunk
Leaky Paywall vtrunk
5.1.9 5.1.8 5.1.7 5.1.6 5.1.5 5.1.4 5.1.3 5.1.2 5.1.1 5.1.0 5.0.9 4.16.17 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.17.0 4.17.1 4.17.2 4.18.0 4.18.1 All 180 releases
leaky-paywall / include / error-tracking.php

error-tracking.php in Leaky Paywall trunk, at include/error-tracking.php

67 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! function_exists( 'leaky_paywall_errors' ) ) {
4 /**
5 * Stores error messages
6 *
7 * @since 1.0
8 */
9 function leaky_paywall_errors() {
10 static $wp_error; // Will hold global variable safely.
11 return isset( $wp_error ) ? $wp_error : ( $wp_error = new WP_Error( null, null, null ) );
12 }
13 }
14
15 /**
16 * Retrieves the HTML for error messages
17 *
18 * @access public
19 * @since 4.0.0
20 */
21 function leaky_paywall_get_error_messages_html( $error_id = '' ) {
22
23 $html = '';
24 $errors = leaky_paywall_errors()->get_error_codes();
25
26 if ( $errors ) {
27
28 $html .= '<div class="leaky_paywall_message error">';
29 // Loop error codes and display errors.
30 foreach ( $errors as $code ) {
31
32 if ( leaky_paywall_errors()->get_error_data( $code ) == $error_id ) {
33
34 $message = leaky_paywall_errors()->get_error_message( $code );
35
36 $html .= '<p class="leaky_paywall_error ' . esc_attr( $code ) . '"><span>' . $message . '</span></p>';
37
38 }
39 }
40
41 $html .= '</div>';
42
43 }
44
45 return apply_filters( 'leaky_paywall_error_messages_html', $html, $errors );
46
47 }
48
49 /**
50 * Displays the HTML for error messages
51 *
52 * @access public
53 * @since 4.0.0
54 *
55 * @param string $error_id The error id.
56 */
57 function leaky_paywall_show_error_messages( $error_id = '' ) {
58
59 if ( leaky_paywall_errors()->get_error_codes() ) {
60
61 do_action( 'leaky_paywall_errors_before' );
62 echo wp_kses_post( leaky_paywall_get_error_messages_html( $error_id ) );
63 do_action( 'leaky_paywall_errors_after' );
64
65 }
66 }
67