$message, 'context' => $context, 'time' => wp_date( 'Y-m-d H:i:s' ) ]; if ( count( $errors ) > self::MAX_ERRORS ) { $errors = array_slice( $errors, -self::MAX_ERRORS ); } update_option( self::$namespace . '_errors', $errors, false ); } $context_str = ''; if ( ! empty($context) ) { $context_str = ' | ' . wp_json_encode($context); } error_log('['. self::$namespace .'] ' . $message . $context_str); } /** * Show latest errors in the admin UI. */ public static function render_admin_notice() { if ( ! current_user_can( 'manage_options' ) ) { return; } $errors = get_option( self::$namespace . '_errors' ); if ( empty( $errors ) || ! is_array( $errors ) ) { return; } $nonce_action = self::$namespace . '_clear_error'; $nonce_name = self::$namespace . '_error_nonce'; $dismiss_url = wp_nonce_url( add_query_arg( $nonce_action, '1' ), $nonce_action, $nonce_name ); echo '
%s:
', esc_html( self::$source ) ); echo '' .
esc_html( wp_json_encode( $error['context'], JSON_PARTIAL_OUTPUT_ON_ERROR ) ) .
'';
}
printf(
'