Last active
January 4, 2016 06:09
-
-
Save lewismcarey/8579853 to your computer and use it in GitHub Desktop.
Create WordPress preview whilst maintaining a holding page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( !isset( $_SESSION ) ) // if no session | |
{ | |
session_start(); // begin session | |
} | |
if ( $_SESSION['preview'] == "allow" || $_GET['preview'] == "allow" ) // if preview GET value exists (or preview SESSION) | |
{ | |
if ( $_GET['preview'] == "allow" ) { | |
$_SESSION['preview'] = "allow"; // create the session - this means you only need to append '?preview=allow' once | |
} | |
if ( $_GET['preview'] == "end" ) { // if the user wishes to exit preview | |
unset($SESSION); | |
session_destroy(); | |
} | |
/** | |
* Front to the WordPress application. This file doesn't do anything, but loads | |
* wp-blog-header.php which does and tells WordPress to load the theme. | |
* | |
* @package WordPress | |
*/ | |
/** | |
* Tells WordPress to load the WordPress theme and output it. | |
* | |
* @var bool | |
*/ | |
define('WP_USE_THEMES', true); | |
/** Loads the WordPress Environment and Template */ | |
require( dirname( __FILE__ ) . '/wp-blog-header.php' ); | |
} else { | |
// this is where your holding page goes | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WORDPRESS Live Preview | |
This wrapper allows you to maintain a HTML holding page whislt seetting up a preview of a live WP site. | |
This is handy if you tend to work locally and don't intend to set up a remote test environment. | |
## Usage | |
http://www.yourwebsite.com?preview=allow | |
http://www.yourwebsite.com?preview=end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment