Skip to content

Instantly share code, notes, and snippets.

@Blake-C
Created January 22, 2016 14:20
Show Gist options
  • Save Blake-C/9a87d095aca728482aea to your computer and use it in GitHub Desktop.
Save Blake-C/9a87d095aca728482aea to your computer and use it in GitHub Desktop.
PHP Back Button
<?php
$allowed_host = $_SERVER['SERVER_NAME'];
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
?>
<?php if( substr($host, 0 - strlen($allowed_host)) == $allowed_host ) : ?>
<br><p><a class="btn btn-primary" href="<?php echo $_SERVER['HTTP_REFERER'];?>">Back to list</a></p>
<?php else : ?>
<br><p><a class="btn btn-primary" href="<?php echo get_post_type_archive_link('associate-members'); ?>">Back to list</a></p>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment