PluginProbe
WPIDE – File Manager & Code Editor / 3.5.9
WPIDE – File Manager & Code Editor v3.5.9
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
← All changes | freemius/includes/class-fs-admin-notices.php +56 -24 3.33.5.9 View file →
@@ -124,15 +124,12 @@
124 124 $type = 'success',
125 125 $is_sticky = false,
126 126 $id = '',
127 127 $store_if_sticky = true,
128 - $network_level_or_blog_id = null
128 + $network_level_or_blog_id = null,
129 + $is_dimissible = null
129 130 ) {
130 - if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) {
131 - $notices = $this->_network_notices;
132 - } else {
133 - $notices = $this->get_site_notices( $network_level_or_blog_id );
134 - }
131 + $notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
135 132
136 133 $notices->add(
137 134 $message,
138 135 $title,
@@ -138,9 +135,13 @@
138 135 $title,
139 136 $type,
140 137 $is_sticky,
141 138 $id,
142 - $store_if_sticky
139 + $store_if_sticky,
140 + null,
141 + null,
142 + false,
143 + $is_dimissible
143 144 );
144 145 }
145 146
146 147 /**
@@ -148,10 +149,11 @@
148 149 * @since 1.0.7
149 150 *
150 151 * @param string|string[] $ids
151 152 * @param int|null $network_level_or_blog_id
153 + * @param bool $store
152 154 */
153 - function remove_sticky( $ids, $network_level_or_blog_id = null ) {
155 + function remove_sticky( $ids, $network_level_or_blog_id = null, $store = true ) {
154 156 if ( ! is_array( $ids ) ) {
155 157 $ids = array( $ids );
156 158 }
157 159
@@ -160,9 +162,9 @@
160 162 } else {
161 163 $notices = $this->get_site_notices( $network_level_or_blog_id );
162 164 }
163 165
164 - return $notices->remove_sticky( $ids );
166 + return $notices->remove_sticky( $ids, $store );
165 167 }
166 168
167 169 /**
168 170 * Check if sticky message exists by id.
@@ -175,13 +177,9 @@
175 177 *
176 178 * @return bool
177 179 */
178 180 function has_sticky( $id, $network_level_or_blog_id = null ) {
179 - if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) {
180 - $notices = $this->_network_notices;
181 - } else {
182 - $notices = $this->get_site_notices( $network_level_or_blog_id );
183 - }
181 + $notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
184 182
185 183 return $notices->has_sticky( $id );
186 184 }
187 185
@@ -199,8 +197,9 @@
199 197 * @param number|null $wp_user_id
200 198 * @param string|null $plugin_title
201 199 * @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
202 200 * blog admin pages.
201 + * @param bool $is_dismissible
203 202 */
204 203 function add_sticky(
205 204 $message,
206 205 $id,
@@ -208,20 +207,35 @@
208 207 $type = 'success',
209 208 $network_level_or_blog_id = null,
210 209 $wp_user_id = null,
211 210 $plugin_title = null,
212 - $is_network_and_blog_admins = false
211 + $is_network_and_blog_admins = false,
212 + $is_dismissible = true,
213 + $data = array()
213 214 ) {
214 - if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) {
215 - $notices = $this->_network_notices;
216 - } else {
217 - $notices = $this->get_site_notices( $network_level_or_blog_id );
218 - }
215 + $notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
219 216
220 - $notices->add_sticky( $message, $id, $title, $type, $wp_user_id, $plugin_title, $is_network_and_blog_admins );
217 + $notices->add_sticky( $message, $id, $title, $type, $wp_user_id, $plugin_title, $is_network_and_blog_admins, $is_dismissible, $data );
221 218 }
222 219
223 220 /**
221 + * Retrieves the data of a sticky notice.
222 + *
223 + * @author Leo Fajardo (@leorw)
224 + * @since 2.4.3
225 + *
226 + * @param string $id
227 + * @param int|null $network_level_or_blog_id
228 + *
229 + * @return array|null
230 + */
231 + function get_sticky( $id, $network_level_or_blog_id ) {
232 + $notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id );
233 +
234 + return $notices->get_sticky( $id );
235 + }
236 +
237 + /**
224 238 * Clear all sticky messages.
225 239 *
226 240 * @author Vova Feldman (@svovaf)
227 241 * @since 2.0.0
@@ -226,10 +240,11 @@
226 240 * @author Vova Feldman (@svovaf)
227 241 * @since 2.0.0
228 242 *
229 243 * @param int|null $network_level_or_blog_id
244 + * @param bool $is_temporary
230 245 */
231 - function clear_all_sticky( $network_level_or_blog_id = null ) {
246 + function clear_all_sticky( $network_level_or_blog_id = null, $is_temporary = false ) {
232 247 if ( ! $this->_is_multisite ||
233 248 false === $network_level_or_blog_id ||
234 249 0 == $network_level_or_blog_id ||
235 250 is_null( $network_level_or_blog_id )
@@ -234,15 +249,15 @@
234 249 0 == $network_level_or_blog_id ||
235 250 is_null( $network_level_or_blog_id )
236 251 ) {
237 252 $notices = $this->get_site_notices( $network_level_or_blog_id );
238 - $notices->clear_all_sticky();
253 + $notices->clear_all_sticky( $is_temporary );
239 254 }
240 255
241 256 if ( $this->_is_multisite &&
242 257 ( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
243 258 ) {
244 - $this->_network_notices->clear_all_sticky();
259 + $this->_network_notices->clear_all_sticky( $is_temporary );
245 260 }
246 261 }
247 262
248 263 /**
@@ -314,8 +329,25 @@
314 329 return $network_level_or_blog_id;
315 330 }
316 331
317 332 return fs_is_network_admin();
333 + }
334 +
335 + /**
336 + * Retrieves an instance of FS_Admin_Notice_Manager.
337 + *
338 + * @author Leo Fajardo (@leorw)
339 + * @since 2.5.0
340 + *
341 + * @param string $id
342 + * @param int|null $network_level_or_blog_id
343 + *
344 + * @return FS_Admin_Notice_Manager
345 + */
346 + private function get_site_or_network_notices( $id, $network_level_or_blog_id ) {
347 + return $this->should_use_network_notices( $id, $network_level_or_blog_id ) ?
348 + $this->_network_notices :
349 + $this->get_site_notices( $network_level_or_blog_id );
318 350 }
319 351
320 352 #endregion
321 353 }