Skip to content

Instantly share code, notes, and snippets.

@datamafia
Created March 5, 2015 16:26
Show Gist options
  • Save datamafia/5e5773b858a1c208f3b8 to your computer and use it in GitHub Desktop.
Save datamafia/5e5773b858a1c208f3b8 to your computer and use it in GitHub Desktop.
Wordpress development script for previews
<?php
/*
Install this in your theme header.php as the first statement
(next line right after the <?php opening tag)
Change $magic_word to what ever variable you want to use,
default is "preview"
To use this, go to yoursite.com?preview and a session will
be created and access to the site will last as long as the
session endures. Use yoursite.com?preview to refresh the session.
Session length varies. 1-6 hour minimum is common.
When you want to kick it live, just delete these lines.
*/
// Dev preview
$magic_word = 'preview';
session_start();
if (isset($_GET[$magic_word])){
$_SESSION['preview'] = True;
}
if (!$_SESSION['preview']){
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment