Refactor the render() method into multiple methods - one for each section of debug output.
This commit is contained in:
parent
5f08d1135b
commit
dcc0f1ce38
|
|
@ -9,6 +9,8 @@ class PluginUpdateCheckerPanel extends Debug_Bar_Panel {
|
|||
/** @var PluginUpdateChecker */
|
||||
private $updateChecker;
|
||||
|
||||
private $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
|
||||
|
||||
public function __construct($updateChecker) {
|
||||
$this->updateChecker = $updateChecker;
|
||||
$title = sprintf(
|
||||
|
|
@ -26,8 +28,14 @@ class PluginUpdateCheckerPanel extends Debug_Bar_Panel {
|
|||
esc_attr(wp_create_nonce('puc-ajax'))
|
||||
);
|
||||
|
||||
$responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
|
||||
$this->displayConfiguration();
|
||||
$this->displayStatus();
|
||||
$this->displayCurrentUpdate();
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
private function displayConfiguration() {
|
||||
echo '<h3>Configuration</h3>';
|
||||
echo '<table class="puc-debug-data">';
|
||||
$this->row('Plugin file', htmlentities($this->updateChecker->pluginFile));
|
||||
|
|
@ -38,7 +46,7 @@ class PluginUpdateCheckerPanel extends Debug_Bar_Panel {
|
|||
if ( function_exists('get_submit_button') ) {
|
||||
$requestInfoButton = get_submit_button('Request Info', 'secondary', 'puc-request-info-button', false, array('id' => 'puc-request-info-button-' . $this->updateChecker->slug));
|
||||
}
|
||||
$this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl) . ' ' . $requestInfoButton . $responseBox);
|
||||
$this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl) . ' ' . $requestInfoButton . $this->responseBox);
|
||||
|
||||
if ( $this->updateChecker->checkPeriod > 0 ) {
|
||||
$this->row('Automatic checks', 'Every ' . $this->updateChecker->checkPeriod . ' hours');
|
||||
|
|
@ -61,7 +69,9 @@ class PluginUpdateCheckerPanel extends Debug_Bar_Panel {
|
|||
}
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
private function displayStatus() {
|
||||
echo '<h3>Status</h3>';
|
||||
echo '<table class="puc-debug-data">';
|
||||
$state = $this->updateChecker->getUpdateState();
|
||||
|
|
@ -71,7 +81,7 @@ class PluginUpdateCheckerPanel extends Debug_Bar_Panel {
|
|||
}
|
||||
|
||||
if ( isset($state, $state->lastCheck) ) {
|
||||
$this->row('Last check', $this->formatTimeWithDelta($state->lastCheck) . ' ' . $checkNowButton . $responseBox);
|
||||
$this->row('Last check', $this->formatTimeWithDelta($state->lastCheck) . ' ' . $checkNowButton . $this->responseBox);
|
||||
} else {
|
||||
$this->row('Last check', 'Never');
|
||||
}
|
||||
|
|
@ -85,7 +95,9 @@ class PluginUpdateCheckerPanel extends Debug_Bar_Panel {
|
|||
}
|
||||
$this->row('Update checker class', htmlentities(get_class($this->updateChecker)));
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
private function displayCurrentUpdate() {
|
||||
$update = $this->updateChecker->getUpdate();
|
||||
if ( $update !== null ) {
|
||||
echo '<h3>An Update Is Available</h3>';
|
||||
|
|
@ -98,8 +110,6 @@ class PluginUpdateCheckerPanel extends Debug_Bar_Panel {
|
|||
} else {
|
||||
echo '<h3>No updates currently available</h3>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
private function formatTimeWithDelta($unixTime) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue