Debug Bar: Display "Check Now" and "Request Info" in front end
By default, these buttons are generated using the get_submit_button() API function, but that function is only available in the admin dashboard (unless explicitly loaded). Previously, the buttons were not shown in the front end. This patch adds a fallback that generates the buttons directly. These won't look exactly the same as admin buttons due to admin styles not being loaded, and WP may change submit button HTML at some point, but the fallback buttons should still work. Fixes #568
This commit is contained in:
parent
e8e53e6d98
commit
97dfe23d15
|
|
@ -86,14 +86,22 @@ if ( !class_exists(Panel::class, false) && class_exists('Debug_Bar_Panel', false
|
|||
echo '<h3>Status</h3>';
|
||||
echo '<table class="puc-debug-data">';
|
||||
$state = $this->updateChecker->getUpdateState();
|
||||
$checkNowButton = '';
|
||||
$checkButtonId = $this->updateChecker->getUniqueName('check-now-button');
|
||||
if ( function_exists('get_submit_button') ) {
|
||||
$checkNowButton = get_submit_button(
|
||||
'Check Now',
|
||||
'secondary',
|
||||
'puc-check-now-button',
|
||||
false,
|
||||
array('id' => $this->updateChecker->getUniqueName('check-now-button'))
|
||||
array('id' => $checkButtonId)
|
||||
);
|
||||
} else {
|
||||
//get_submit_button() is not available in the frontend. Make a button directly.
|
||||
//It won't look the same without admin styles, but it should still work.
|
||||
$checkNowButton = sprintf(
|
||||
'<input type="button" id="%1$s" name="puc-check-now-button" value="%2$s" class="button button-secondary" />',
|
||||
esc_attr($checkButtonId),
|
||||
esc_attr('Check Now')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,20 @@ if ( !class_exists(PluginPanel::class, false) ):
|
|||
}
|
||||
|
||||
protected function getMetadataButton() {
|
||||
$requestInfoButton = '';
|
||||
$buttonId = $this->updateChecker->getUniqueName('request-info-button');
|
||||
if ( function_exists('get_submit_button') ) {
|
||||
$requestInfoButton = get_submit_button(
|
||||
'Request Info',
|
||||
'secondary',
|
||||
'puc-request-info-button',
|
||||
false,
|
||||
array('id' => $this->updateChecker->getUniqueName('request-info-button'))
|
||||
array('id' => $buttonId)
|
||||
);
|
||||
} else {
|
||||
$requestInfoButton = sprintf(
|
||||
'<input type="button" name="puc-request-info-button" id="%1$s" value="%2$s" class="button button-secondary" />',
|
||||
esc_attr($buttonId),
|
||||
esc_attr('Request Info')
|
||||
);
|
||||
}
|
||||
return $requestInfoButton;
|
||||
|
|
|
|||
Loading…
Reference in New Issue