-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththemebase.php
More file actions
73 lines (60 loc) · 1.64 KB
/
themebase.php
File metadata and controls
73 lines (60 loc) · 1.64 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?
/*
Plugin Name: Themebase
Plugin URI: http://github.com/randomblast/themebase
Description: A set of CMS-minded Wordpress extensions to build a theme on top of.
Author: Josh Channings <randomblast@googlemail.com>
Version: 0.1
Author URI:
*/
/**
* @copyright 2010 Josh Channings <randomblast@googlemail.com>
* @package Themebase
*/
/** Adds support for iTunes-style metadata in MPEG4 containers */
require_once('filetype-mpeg4.php');
/** Image functions */
require_once('image.php');
/** PCP: CSS Proprocessor */
ob_start(); require_once('pcp.php'); ob_end_clean();
/**
* Theme Working Directory.
*
* Shortcut to get_bloginfo('stylesheet_directory')
*/
function twd()
{
return get_bloginfo('stylesheet_directory');
}
// Instantiate PCP
$pcp = new PCP(get_theme_root().'/'.get_template().'/.build/pcp-cache');
/** Get URL of PCP diff */
function tb_pcp_diff()
{
global $post;
$baseurl = '';
extract(wp_upload_dir(), EXTR_IF_EXISTS);
return "$baseurl/pcp-diffs/{$post->ID}.css";
}
/** Generate CSS diff on post-save action */
function tb_generate_css_diff($id)
{
global $pcp;
// Prepare diffs dir
$basedir = '';
extract(wp_upload_dir(), EXTR_IF_EXISTS);
if(!is_dir("$basedir/pcp-diffs"))
mkdir("$basedir/pcp-diffs");
$post = get_post($id);
do_shortcode($post->post_content);
file_put_contents("$basedir/pcp-diffs/$id.css", $pcp->css());
}
/** Cleanup CSS diffs on post_delete action */
function tb_cleanup_css_diff($id)
{
extract(wp_upload_dir());
unlink("$basedir/pcp-diffs/$id.css");
}
add_action('save_post', 'tb_generate_css_diff');
add_action('delete_post', 'tb_cleanup_css_diff');
?>