Skip to content

Instantly share code, notes, and snippets.

@Zodiac1978
Created October 10, 2023 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zodiac1978/5e51fe0d2ecb2343614cb0e565602c01 to your computer and use it in GitHub Desktop.
Save Zodiac1978/5e51fe0d2ecb2343614cb0e565602c01 to your computer and use it in GitHub Desktop.
WordPress plugin preview for from Roy Tanck modified to support Enter key for submit
<!DOCTYPE html>
<html lang="en">
<head>
<title>WordPress plugin preview</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">
<div id="content">
<p>Enter the plugin's slug, for example 'hello-dolly'.</p>
<form id="form">
<input type="text" id="slug"><br>
<input type="submit" id="submit" value="Preview">
</form>
</div>
<p id="credits">&copy; <a href="https://roytanck.com">Roy Tanck</a></p>
</div>
<script>
document.querySelector( '#form' ).addEventListener( 'submit', ( event ) => {
event.preventDefault();
let slug = document.querySelector( '#slug' ).value;
let url = 'https://playground.wordpress.net/?plugin=' + slug + '&login=1&url=/wp-admin/plugins.php';
document.location = url;
} );
document.querySelector( '#submit' ).addEventListener( 'click', ( event ) => {
event.preventDefault();
let slug = document.querySelector( '#slug' ).value;
let url = 'https://playground.wordpress.net/?plugin=' + slug + '&login=1&url=/wp-admin/plugins.php';
document.location = url;
} );
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment