protected function single_install_switcher($theme)
{
$show_button = true;
$options = get_site_option('github_updater');
$nonced_update_url = wp_nonce_url($this->get_update_url('theme', 'upgrade-theme', $theme->repo), 'upgrade-theme_' . $theme->repo);
$rollback_url = sprintf('%s%s', $nonced_update_url, '&rollback=');
ob_start();
if (!empty($options['branch_switch'])) {
printf('<p>' . esc_html__('Current branch is `%1$s`, try %2$sanother version%3$s', 'github-updater'), $theme->branch, '<a href="#" onclick="jQuery(\'#ghu_versions\').toggle();return false;">', '</a>.</p>');
?>
<div id="ghu_versions" style="display:none; width: 100%;">
<label><select style="width: 60%;"
onchange="if(jQuery(this).val() != '') {
jQuery(this).parent().next().show();
jQuery(this).parent().next().attr('href','<?php
echo esc_url($rollback_url);
?>
'+jQuery(this).val());
}
else jQuery(this).parent().next().hide();
">
<option value=""><?php
esc_html_e('Choose a Version', 'github-updater');
?>
…</option>
<?php
foreach (array_keys($theme->branches) as $branch) {
echo '<option>' . $branch . '</option>';
}
if (!empty($theme->rollback)) {
$rollback = array_keys($theme->rollback);
usort($rollback, 'version_compare');
krsort($rollback);
$rollback = array_splice($rollback, 0, 4, true);
array_shift($rollback);
// Dump current tag.
foreach ($rollback as $tag) {
echo '<option>' . $tag . '</option>';
}
}
if (empty($options['branch_switch']) && empty($theme->rollback)) {
echo '<option>' . esc_html__('No previous tags to rollback to.', 'github-updater') . '</option></select></label>';
$show_button = false;
}
?>
</select></label>
<?php
if ($show_button) {
?>
<a style="display: none;" class="button-primary" href="?"><?php
esc_html_e('Install', 'github-updater');
?>
</a>
<?php
}
?>
</div>
<?php
}
return trim(ob_get_clean(), '1');
}