File tree Expand file tree Collapse file tree 3 files changed +78
-0
lines changed
Expand file tree Collapse file tree 3 files changed +78
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ private function getWrapperClasses(AdminNotice $notice): string
5252 $ classes [] = "is-dismissible " ;
5353 }
5454
55+ if ($ notice ->isInline ()) {
56+ $ classes [] = 'inline ' ;
57+ }
58+
5559 return implode (' ' , $ classes );
5660 }
5761}
Original file line number Diff line number Diff line change @@ -65,8 +65,16 @@ class AdminNotice
6565 */
6666 protected $ withWrapper = true ;
6767
68+ /**
69+ * @var bool
70+ */
6871 protected $ dismissible = false ;
6972
73+ /**
74+ * @var bool
75+ */
76+ protected $ inline = false ;
77+
7078 /**
7179 * @since 1.0.0
7280 *
@@ -274,6 +282,40 @@ public function withoutWrapper(): self
274282 return $ this ;
275283 }
276284
285+ /**
286+ * Returns whether the notice is inline
287+ *
288+ * @unreleased
289+ */
290+ public function isInline (): bool
291+ {
292+ return $ this ->inline ;
293+ }
294+
295+ /**
296+ * Sets the notice to be inline
297+ *
298+ * @unreleased
299+ */
300+ public function inline (bool $ inline = true ): self
301+ {
302+ $ this ->inline = $ inline ;
303+
304+ return $ this ;
305+ }
306+
307+ /**
308+ * Sets the notice to be not inline
309+ *
310+ * @unreleased
311+ */
312+ public function notInline (): self
313+ {
314+ $ this ->inline = false ;
315+
316+ return $ this ;
317+ }
318+
277319 /**
278320 * Sets the notice to be dismissible, usable when the notice is displayed in the standard wrapper
279321 *
Original file line number Diff line number Diff line change @@ -244,6 +244,38 @@ public function testWithWrapper(): void
244244 $ this ->assertSame ($ notice , $ self );
245245 }
246246
247+ /**
248+ * @covers ::inline
249+ * @covers ::notInline
250+ * @covers ::isInline
251+ *
252+ * @unreleased
253+ */
254+ public function testInline (): void
255+ {
256+ // Defaults to false
257+ $ notice = new AdminNotice ('test_id ' , 'test ' );
258+ $ this ->assertFalse ($ notice ->isInline ());
259+
260+ // Method defaults to true
261+ $ self = $ notice ->inline ();
262+ $ this ->assertTrue ($ notice ->isInline ());
263+ $ this ->assertSame ($ notice , $ self );
264+
265+ // Method can be explicitly set to false
266+ $ notice ->inline (false );
267+ $ this ->assertFalse ($ notice ->isInline ());
268+
269+ // Method can be set to true
270+ $ notice ->inline (true );
271+ $ this ->assertTrue ($ notice ->isInline ());
272+
273+ // notInline is an alias for inline(false)
274+ $ self = $ notice ->notInline ();
275+ $ this ->assertFalse ($ notice ->isInline ());
276+ $ this ->assertSame ($ notice , $ self );
277+ }
278+
247279 /**
248280 * @covers ::dismissible
249281 * @covers ::notDismissible
You can’t perform that action at this time.
0 commit comments