2009-08-07 19:50:06 +00:00
|
|
|
<?php
|
|
|
|
|
2009-11-17 03:30:35 +00:00
|
|
|
foreach (array(
|
|
|
|
'F' => 3,
|
|
|
|
'Protect' => 0,
|
|
|
|
'Restore' => 0,
|
|
|
|
'Unprotect' => 0,
|
|
|
|
) as $function => $param_count) {
|
|
|
|
if ($param_count == 0) {
|
|
|
|
add_action("comicpress-${function}", $function, 10);
|
|
|
|
} else {
|
|
|
|
add_filter("comicpress-${function}", $function, 10, $param_count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-16 17:46:53 +00:00
|
|
|
// Global template functions for ComicPress
|
2010-02-05 01:55:03 +00:00
|
|
|
// TODO is this even necessary anymore?
|
2009-11-07 22:18:11 +00:00
|
|
|
function F($name, $path, $override_post = null) {
|
|
|
|
global $post;
|
2009-11-08 01:56:49 +00:00
|
|
|
|
2009-11-07 22:18:11 +00:00
|
|
|
$comic_post = new ComicPressComicPost(is_null($override_post) ? $post : $override_post);
|
|
|
|
|
2009-11-13 00:12:30 +00:00
|
|
|
$comicpress = ComicPress::get_instance();
|
|
|
|
return $comicpress->find_file($name, $path, $comic_post->find_parents());
|
2009-11-07 22:18:11 +00:00
|
|
|
}
|
|
|
|
|
2009-11-08 01:56:49 +00:00
|
|
|
/**
|
|
|
|
* Protect global $post and $wp_query.
|
2009-11-19 12:27:10 +00:00
|
|
|
* @param object $use_this_post If provided, after saving the current post, set up this post for template tag use.
|
2009-11-08 01:56:49 +00:00
|
|
|
*/
|
2009-11-19 02:25:35 +00:00
|
|
|
function Protect($use_this_post = null) {
|
2009-11-08 01:56:49 +00:00
|
|
|
global $post, $wp_query, $__post, $__wp_query;
|
|
|
|
|
|
|
|
$__post = $post;
|
|
|
|
$__wp_query = $wp_query;
|
2009-11-19 02:25:35 +00:00
|
|
|
|
|
|
|
if (!is_null($use_this_post)) {
|
|
|
|
$post = $use_this_post;
|
|
|
|
setup_postdata($post);
|
|
|
|
}
|
2009-11-08 01:56:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-08 03:00:14 +00:00
|
|
|
/**
|
|
|
|
* Temporarily restore the global $post variable and set it up for use.
|
|
|
|
*/
|
|
|
|
function Restore() {
|
|
|
|
global $post, $__post;
|
|
|
|
|
|
|
|
$post = $__post;
|
|
|
|
setup_postdata($post);
|
|
|
|
}
|
|
|
|
|
2009-11-08 01:56:49 +00:00
|
|
|
/**
|
|
|
|
* Restore global $post and $wp_query.
|
|
|
|
*/
|
2009-11-08 03:00:14 +00:00
|
|
|
function Unprotect() {
|
2009-11-08 01:56:49 +00:00
|
|
|
global $post, $wp_query, $__post, $__wp_query;
|
|
|
|
|
|
|
|
$post = $__post;
|
|
|
|
$wp_query = $__wp_query;
|
|
|
|
|
|
|
|
$__post = $__wp_query = null;
|
|
|
|
}
|