Skip to content

Instantly share code, notes, and snippets.

@jackbillstrom
Created February 18, 2020 14: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 jackbillstrom/6939e7fb4ccd09936610f8e2d99e0f97 to your computer and use it in GitHub Desktop.
Save jackbillstrom/6939e7fb4ccd09936610f8e2d99e0f97 to your computer and use it in GitHub Desktop.
DOCUMENTATION: https://sweetalert2.github.io | SIMPLE WORDPRESS FUNCTION FOR INJECTING A MODAL WITH REMOTE RESOURCES
function custom_inject() {
// promise-polyfill - Lär dig var det används för
echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.8.3/polyfill.min.js"></script>';
echo '<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>';
echo '<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.css" />';
// Nu har alla nödvändiga filer lästs in, vi är redo att anropa popup
echo <<<EOL
<script>
Swal.fire({
title: "AM's fotvård har tagits över av Mitt i Livet",
icon: "info",
html:
"<p>Vi hälsar både nya och gamla kunder välkomna till samma salong. Bokar tid gör ni enklast på knappen nedan</p>",
showCloseButton: true,
showCancelButton: true,
focusConfirm: true,
confirmButtonText:
"Se lediga tider & boka behandling",
confirmButtonAriaLabel: "Se lediga tider & boka behandling",
cancelButtonText:
"Fortsätt till hemsidan",
cancelButtonAriaLabel: "Fortsätt till hemsidan"
});
</script>
EOL;
}
// Kalla funktionen som skriver HTML kod till våran WORDPRESS FOOTER
add_action( 'wp_footer', 'custom_inject' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment