Skip to content

Instantly share code, notes, and snippets.

@onliniak
Last active November 28, 2019 23:11
Show Gist options
  • Save onliniak/99341adbf35ab3ac2a52f4f61e0caafd to your computer and use it in GitHub Desktop.
Save onliniak/99341adbf35ab3ac2a52f4f61e0caafd to your computer and use it in GitHub Desktop.
WordPress as UUID4 Validator
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php';
$select = file_get_contents('php://input');
if(empty($select)) {
echo wp_generate_uuid4();
}else{
wp_is_uuid( $select, 4 );
echo 'UUID is correct';
}
function GUID_get() {
fetch("guid.php")
.then((res) => {
return res.text();
})
.then((data) => {
sessionStorage.setItem("UUID", data);
console.log('UUID generated succesfull')
})};
function GUID() {
fetch("guid.php", {
method: "POST",
body: sessionStorage.getItem('UUID')
})
.then((res) => {
return res.text();
})
.then((data) => {
console.log(data)
})};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment