PluginProbe
Stream – Activity Log & Audit Trail / 3.9.0
Stream – Activity Log & Audit Trail v3.9.0
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
← All changes | alerts/class-alert-type-menu-alert.php +46 -30 3.2.13.9.0 View file →
@@ -12,8 +12,9 @@
12 12 *
13 13 * @package WP_Stream
14 14 */
15 15 class Alert_Type_Menu_Alert extends Alert_Type {
16 +
16 17 /**
17 18 * Alert type name
18 19 *
19 20 * @var string
@@ -47,9 +48,8 @@
47 48 * @return void
48 49 */
49 50 public function alert( $record_id, $recordarr, $options ) {
50 51 $this->add_message( $recordarr['summary'] );
51 - return;
52 52 }
53 53
54 54 /**
55 55 * Displays a settings form for the alert type
@@ -61,21 +61,27 @@
61 61 $alert_meta = array();
62 62 if ( is_object( $alert ) ) {
63 63 $alert_meta = $alert->alert_meta;
64 64 }
65 - $options = wp_parse_args( $alert_meta, array(
66 - 'clear_immediate' => false,
67 - ) );
65 + $options = wp_parse_args(
66 + $alert_meta,
67 + array(
68 + 'clear_immediate' => false,
69 + )
70 + );
68 71
69 - $form = new Form_Generator;
70 - $form->add_field( 'checkbox', array(
71 - 'name' => 'wp_stream_menu_alert_clear_immediate',
72 - 'text' => esc_attr( __( 'Clear alerts after seen.', 'stream' ) ),
73 - 'value' => $options['clear_immediate'],
74 - 'title' => __( 'Menu Bar', 'stream' ),
75 - ) );
72 + $form = new Form_Generator();
73 + $form->add_field(
74 + 'checkbox',
75 + array(
76 + 'name' => 'wp_stream_menu_alert_clear_immediate',
77 + 'text' => esc_attr( __( 'Clear alerts after seen.', 'stream' ) ),
78 + 'value' => $options['clear_immediate'],
79 + 'title' => __( 'Menu Bar', 'stream' ),
80 + )
81 + );
76 82
77 - echo $form->render_all(); // Xss ok.
83 + echo $form->render_fields(); // Xss ok.
78 84 }
79 85
80 86 /**
81 87 * Validates and saves form settings for later use.
@@ -100,27 +106,36 @@
100 106 if ( ! $messages ) {
101 107 return false;
102 108 }
103 109
104 - $wp_admin_bar->add_node( array(
105 - 'id' => 'wp_stream_alert_notify',
106 - 'parent' => false,
107 - 'title' => __( 'New Stream Alert', 'stream' ),
108 - 'href' => '#',
109 - 'meta' => array( 'class' => 'opposite' ),
110 - ) );
110 + $wp_admin_bar->add_node(
111 + array(
112 + 'id' => 'wp_stream_alert_notify',
113 + 'parent' => false,
114 + 'title' => __( 'New Stream Alert', 'stream' ),
115 + 'href' => '#',
116 + 'meta' => array(
117 + 'class' => 'opposite',
118 + ),
119 + )
120 + );
111 121
112 122 foreach ( $messages as $key => $message ) {
113 - $wp_admin_bar->add_node( array(
114 - 'id' => 'wp_stream_alert_notify_' . $key,
115 - 'parent' => 'wp_stream_alert_notify',
116 - 'title' => esc_html( $message ),
117 - 'href' => '#',
118 - 'meta' => array( 'class' => 'opposite' ),
119 - ) );
123 + $wp_admin_bar->add_node(
124 + array(
125 + 'id' => 'wp_stream_alert_notify_' . $key,
126 + 'parent' => 'wp_stream_alert_notify',
127 + 'title' => esc_html( $message ),
128 + 'href' => '#',
129 + 'meta' => array(
130 + 'class' => 'opposite',
131 + ),
132 + )
133 + );
120 134 }
121 135
122 136 $this->clear_messages();
137 +
123 138 return true;
124 139 }
125 140
126 141 /**
@@ -130,10 +145,11 @@
130 145 *
131 146 * @return array List of alert messages
132 147 */
133 148 public function get_messages() {
134 - $current_user = wp_get_current_user();
135 - $messages = get_user_meta( $current_user->ID, $this->get_key(), false );
149 + $current_user = wp_get_current_user();
150 + $messages = get_user_meta( $current_user->ID, $this->get_key(), false );
151 +
136 152 return $messages;
137 153 }
138 154
139 155 /**
@@ -144,9 +160,9 @@
144 160 * @param string $message Alert message to add.
145 161 * @return void
146 162 */
147 163 public function add_message( $message ) {
148 - $current_user = wp_get_current_user();
164 + $current_user = wp_get_current_user();
149 165 add_user_meta( $current_user->ID, $this->get_key(), $message, false );
150 166 }
151 167
152 168 /**
@@ -157,9 +173,9 @@
157 173 * @param bool $global Whether to clear globally.
158 174 * @return void
159 175 */
160 176 public function clear_messages( $global = false ) {
161 - $current_user = wp_get_current_user();
177 + $current_user = wp_get_current_user();
162 178 delete_user_meta( $current_user->ID, $this->get_key(), $global );
163 179 }
164 180
165 181 /**