[WordPress] WordPress Widgets: Refactoring, Part 12
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
<?php | |
namespace WordPressWidgetBoilerplate\WordPress; | |
class WidgetDisplay | |
{ | |
private $widgetSlug; | |
public function __construct(string $widgetSlug) | |
{ | |
$this->widgetSlug = $widgetSlug; | |
} | |
public function show($args, $instance) | |
{ | |
// More to come | |
} | |
} |
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
<?php | |
public function widget($args, $instance) | |
{ | |
return $this->widgetDisplay->show($args, $instance); | |
} |
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
<?php | |
public function __construct($widgetSlug) | |
{ | |
parent::__construct($widgetSlug); | |
$this->widgetSerializer = new WidgetSerializer($this->getWidgetSlug()); | |
$this->widgetDisplay = new WidgetDisplay($this->getWidgetSlug()); | |
} |
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
<div id="<?php echo $args['id']; ?>"> | |
<h3 class="widget-title"><?php echo $instance['title']; ?></h3> | |
<p><?php echo $instance['content']; ?></p> | |
<pre><?php echo $instance['display-title']; ?></pre> | |
</div><!-- #<?php echo $args['id']; ?>--> |
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
<?php | |
public function show($args, $instance) | |
{ | |
include_once 'Views/Widget.php'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment