Skip to content

Instantly share code, notes, and snippets.

@j4ckth3r1pp3r
Last active September 12, 2016 13:45
Show Gist options
  • Save j4ckth3r1pp3r/0ae3101b18dc8cb0ec4c078523cf01cf to your computer and use it in GitHub Desktop.
Save j4ckth3r1pp3r/0ae3101b18dc8cb0ec4c078523cf01cf to your computer and use it in GitHub Desktop.
JSON template for WP use
<?php
define('WP_USE_THEMES', false);
preg_match('/(.*)wp-content/', __DIR__, $matches);
$root_folder = $matches[1];
require( $root_folder.'/wp-blog-header.php' );
$json = $_GET['json'];
if ( $json == 1 )
{
$json_data = array();
header('Content-Type: application/json');
echo json_encode($json_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
} else {
echo 'GTFO, kek';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment