Skip to content

Instantly share code, notes, and snippets.

@Shocker
Last active October 31, 2026 11:56
Show Gist options
  • Select an option

  • Save Shocker/4af028a0228ec464424cc79f2da58a37 to your computer and use it in GitHub Desktop.

Select an option

Save Shocker/4af028a0228ec464424cc79f2da58a37 to your computer and use it in GitHub Desktop.
Adminer - Plugin - Delete row button (for Adminer http://www.adminer.org)
<?php
/**
* Add delete row link near edit row link in table select
* @category Plugin
* @author Shocker
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
*/
class AdminerDeleteRowButton extends Adminer\Plugin
{
function head()
{
if (!\Adminer\connection())
return;
?>
<script <?= Adminer\nonce() ?>>
document.addEventListener('DOMContentLoaded', function ()
{
qsa("form [data-onclick='tableClick()'] a.edit").forEach(function (editLink)
{
const delBtn = document.createElement('a');
delBtn.href = '#';
delBtn.className = 'delete';
delBtn.textContent = 'delete';
delBtn.style.marginRight = '6px';
delBtn.style.color = '#b00';
editLink.insertAdjacentElement('beforebegin', delBtn);
delBtn.addEventListener('click', function (e)
{
if (e.shiftKey || confirm("Are you sure you want to delete this row?")) // use SHIFT key to bypass confirmation
{
// uncheck all rows
qsa("[name='check[]'").forEach(function(input) { input.checked = false; })
// check current row
this.parentNode.getElementsByTagName("input")[0].checked = true;
// perform click on delete button which has the click handlers
const deleteButton = qs('[name="delete"]');
deleteButton.disabled = false; // enable button in case it's disabled due to no rows being selected before this
deleteButton.dataset.onclick = ""; // prevent click confirmation from the actual delete button
deleteButton.click();
}
e.preventDefault();
});
});
});
</script>
<?php
}
// AI translations
protected $translations = array(
'cs' => array('' => 'Přidat odkaz na smazání řádku vedle odkazu na úpravu řádku ve výběru tabulky'),
'de' => array('' => 'Link zum Löschen einer Zeile neben dem Link zum Bearbeiten einer Zeile in der Tabellenauswahl hinzufügen'),
'ja' => array('' => 'テーブル選択で「行を編集」リンクの横に「行を削除」リンクを追加'),
'pl' => array('' => 'Dodanie linku usuwania wiersza obok linku edycji wiersza w wyborze tabeli'),
'ro' => array('' => 'Adaugă link de ștergere rând lângă linkul de editare rând la tabele'),
'sk' => array('' => 'Pridať odkaz na vymazanie riadku vedľa odkazu na úpravu riadku vo výbere tabuľky'),
'zh' => array('' => '在表格选择中,在编辑行链接旁添加删除行链接'),
);
}
?>
@Shocker

Shocker commented Oct 31, 2026

Copy link
Copy Markdown
Author
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment