|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Feedback class used to give the user feedback during import. |
|
5
|
|
|
* |
|
6
|
|
|
* @package WordPoints_Import |
|
7
|
|
|
* @since 1.0.0 |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class to use to provide feedback to a user while a process is running. |
|
12
|
|
|
* |
|
13
|
|
|
* Examples of processes where this might be useful are upgrades and imports. |
|
14
|
|
|
* |
|
15
|
|
|
* @since 1.0.0 |
|
16
|
|
|
*/ |
|
17
|
|
|
class WordPoints_Importer_Feedback { |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Send an info message. |
|
21
|
|
|
* |
|
22
|
|
|
* Use this to give the user any info that wouldn't be handles by the other |
|
23
|
|
|
* methods. |
|
24
|
|
|
* |
|
25
|
|
|
* @since 1.0.0 |
|
26
|
|
|
* |
|
27
|
|
|
* @param string $message The info message. |
|
28
|
|
|
*/ |
|
29
|
|
|
public function info( $message ) { |
|
30
|
|
|
$this->_send( $message, 'info' ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Send a success message. |
|
35
|
|
|
* |
|
36
|
|
|
* Use this when you want to let the user know that something was a success. |
|
37
|
|
|
* |
|
38
|
|
|
* @since 1.0.0 |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $message The success message. |
|
41
|
|
|
*/ |
|
42
|
|
|
public function success( $message ) { |
|
43
|
|
|
$this->_send( $message, 'success' ); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Send an error message. |
|
48
|
|
|
* |
|
49
|
|
|
* Use this when you want to let the user know that there was an error. |
|
50
|
|
|
* |
|
51
|
|
|
* @since 1.0.0 |
|
52
|
|
|
* |
|
53
|
|
|
* @param string $message The error message. |
|
54
|
|
|
*/ |
|
55
|
|
|
public function error( $message ) { |
|
56
|
|
|
$this->_send( $message, 'error' ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Send a warning message. |
|
61
|
|
|
* |
|
62
|
|
|
* Use this to warn the user about something. A warning doesn't necessarily imply |
|
63
|
|
|
* an error, but that something unexpected has occured that the user might need |
|
64
|
|
|
* to know. |
|
65
|
|
|
* |
|
66
|
|
|
* @since 1.0.0 |
|
67
|
|
|
* |
|
68
|
|
|
* @param string $message The warning message. |
|
69
|
|
|
*/ |
|
70
|
|
|
public function warning( $message ) { |
|
71
|
|
|
$this->_send( $message, 'warning' ); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
// |
|
75
|
|
|
// Protected Methods. |
|
76
|
|
|
// |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Send a message to the user. |
|
80
|
|
|
* |
|
81
|
|
|
* @since 1.0.0 |
|
82
|
|
|
* |
|
83
|
|
|
* @param string $message The feedback message. |
|
84
|
|
|
* @param string $type The type of message: 'info' (defuault), 'sucess', |
|
85
|
|
|
* 'error', 'warning'. |
|
86
|
|
|
*/ |
|
87
|
|
|
protected function _send( $message, $type = 'info' ) { // @codingStandardsIgnoreLine |
|
88
|
|
|
|
|
89
|
|
|
?> |
|
90
|
|
|
|
|
91
|
|
|
<p class="wordpoints-feedback wordpoints-feedback-<?php echo esc_attr( $type ); ?>"> |
|
92
|
|
|
<?php echo wp_kses( $message, 'wordpoints_importer_feedback' ); ?> |
|
93
|
|
|
</p> |
|
94
|
|
|
|
|
95
|
|
|
<?php |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
// EOF |
|
100
|
|
|
|