-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor notices to use the component/view system
- Loading branch information
Showing
6 changed files
with
76 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php declare( strict_types=1 ); | ||
|
||
namespace StellarWP\Uplink\Notice; | ||
|
||
use StellarWP\Uplink\Components\Controller; | ||
|
||
/** | ||
* Renders a notice. | ||
*/ | ||
final class Notice_Controller extends Controller { | ||
|
||
public const VIEW = 'admin/notice'; | ||
|
||
/** | ||
* Render a notice. | ||
* | ||
* @see Notice::toArray() | ||
* @see src/views/admin/notice.php | ||
* | ||
* @param array{type?: string, message?: string, dismissible?: bool, alt?: bool, large?: bool} $args The notice. | ||
* | ||
* @return void | ||
*/ | ||
public function render( array $args = [] ): void { | ||
$classes = [ | ||
'notice', | ||
sprintf( 'notice-%s', $args['type'] ), | ||
$args['dismissible'] ? 'is-dismissible' : '', | ||
$args['alt'] ? 'notice-alt' : '', | ||
$args['large'] ? 'notice-large' : '', | ||
]; | ||
|
||
echo $this->view->render( self::VIEW, [ | ||
'message' => $args['message'], | ||
'classes' => $this->classes( $classes ) | ||
] ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php declare( strict_types=1 ); | ||
/** | ||
* Render a WordPress dashboard notice. | ||
* | ||
* @see \StellarWP\Uplink\Notice\Notice_Controller | ||
* | ||
* @var \League\Plates\Template\Template $this | ||
* @var string $message The message to display. | ||
* @var string $classes The CSS classes for the notice. | ||
*/ | ||
?> | ||
<div class="<?php echo esc_attr( $classes ) ?>"> | ||
<p><?php echo esc_html( $message ) ?></p> | ||
</div> |