-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwordpress-puppetmaster.php
42 lines (38 loc) · 1.27 KB
/
wordpress-puppetmaster.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
Plugin Name: Wordpress Puppetmaster
Plugin URI: http://www.github.com/cts/wordpress-puppetmaster
Description: Turns Wordpress into a data rendering API.
Version: 0.1
Author: The Haystack Group @ MIT
Author URI: http://haystack.csail.mit.edu/
*/
include_once('database-utils.php');
// Turn on error reporting
ini_set('display_errors', 1);
error_reporting(~0);
function puppetmaster()
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if ((isset($_POST['resetblog'])) && ($_POST['resetblog'] == '1'))
{
resetDatabase();
if (isset($_POST['newdata']))
{
// $json = json_decode(file_get_contents($_POST['newdata'], true));
chdir(__DIR__);
//$path = getcwd();
//$path .="/";
//$path .=$_POST['newdata'];
$path = realpath($_POST['newdata']);
$map = file_get_contents($path, true);
$json = json_decode($map, true);
loadBlogData($json);
}
}
}
}
// Tells Wordpress to run puppetmaster() early on in the rendering pipeline, which can be found here:
// http://codex.wordpress.org/Plugin_API/Action_Reference
add_action('plugins_loaded', 'puppetmaster');