quotes are not magic

This commit is contained in:
John Bintz 2009-08-07 15:50:06 -04:00
parent f3c2fa1e1c
commit 05d9e1bc56
2 changed files with 232 additions and 238 deletions

View File

@ -575,7 +575,7 @@ class ComicPressAddonCore extends ComicPressAddon {
function handle_update_override_partial($info) { function handle_update_override_partial($info) {
switch ($info['action']) { switch ($info['action']) {
case __('Update partial', 'comicpress'): case __('Update partial', 'comicpress'):
$this->comicpress->comicpress_options['override_partials'][$info['partial']] = $info['code']; $this->comicpress->comicpress_options['override_partials'][$info['partial']] = stripslashes($info['code']);
break; break;
case __('Delete override partial', 'comicpress'): case __('Delete override partial', 'comicpress'):
unset($this->comicpress->comicpress_options['override_partials'][$info['partial']]); unset($this->comicpress->comicpress_options['override_partials'][$info['partial']]);
@ -643,4 +643,4 @@ class ComicPressAddonCore extends ComicPressAddon {
} }
} }
?> ?>

View File

@ -1,236 +1,230 @@
<?php <?php
// load all of the comic & non-comic category information // load all of the comic & non-comic category information
add_action('init', '__comicpress_init'); add_action('init', '__comicpress_init');
function __comicpress_init() { function __comicpress_init() {
global $comicpress, $wp_query; global $comicpress, $wp_query;
if (current_user_can('edit_files')) { if (current_user_can('edit_files')) {
wp_cache_flush(); wp_cache_flush();
} }
foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) { foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) {
if (is_file($file)) { require_once($file); } if (is_file($file)) { require_once($file); }
} }
$comicpress = new ComicPress(); $comicpress = new ComicPress();
$comicpress->init(); $comicpress->init();
$addons = array(); $addons = array();
if (get_magic_quotes_gpc()) { if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) {
$_POST = array_map('stripslashes_deep', $_POST); $entries = glob($addons_dir . '/*');
$_GET = array_map('stripslashes_deep', $_GET); if (is_array($entries)) {
$_REQUEST = array_map('stripslashes_deep', $_REQUEST); foreach ($entries as $entry) {
} if (is_dir($entry)) {
$classname = basename($entry);
if (is_dir($addons_dir = (dirname(__FILE__) . '/addons'))) { if (file_exists($entry . "/${classname}.inc")) {
$entries = glob($addons_dir . '/*'); require_once($entry . "/${classname}.inc");
if (is_array($entries)) { $classname = "ComicPressAddon${classname}";
foreach ($entries as $entry) { if (class_exists($classname)) {
if (is_dir($entry)) { $addon =& new $classname();
$classname = basename($entry);
if (file_exists($entry . "/${classname}.inc")) { $addon->init(&$comicpress);
require_once($entry . "/${classname}.inc"); if (current_user_can('edit_posts')) {
$classname = "ComicPressAddon${classname}"; if (is_array($_REQUEST['cp'])) {
if (class_exists($classname)) { if (isset($_REQUEST['cp']['_nonce'])) {
$addon =& new $classname(); if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) {
if (method_exists($addon, 'handle_update')) {
$addon->init(&$comicpress); $addon->handle_update();
if (current_user_can('edit_posts')) { $comicpress->load();
if (is_array($_REQUEST['cp'])) { }
if (isset($_REQUEST['cp']['_nonce'])) { }
if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) { }
if (method_exists($addon, 'handle_update')) { }
$addon->handle_update(); if (is_admin()) {
$comicpress->load(); add_action('admin_notices', array(&$addon, 'display_messages'));
} } else {
} add_action('wp_head', array(&$addon, 'display_messages'));
} }
} }
if (is_admin()) { $addons[] = $addon;
add_action('admin_notices', array(&$addon, 'display_messages')); }
} else { }
add_action('wp_head', array(&$addon, 'display_messages')); }
} }
} }
$addons[] = $addon; }
}
} $layouts = $comicpress->get_layout_choices();
} if (isset($layouts[$comicpress->comicpress_options['layout']])) {
} if (isset($layouts[$comicpress->comicpress_options['layout']]['Sidebars'])) {
} foreach (explode(",", $layouts[$comicpress->comicpress_options['layout']]['Sidebars']) as $sidebar) {
} $sidebar = trim($sidebar);
register_sidebar($sidebar);
$layouts = $comicpress->get_layout_choices(); }
if (isset($layouts[$comicpress->comicpress_options['layout']])) { }
if (isset($layouts[$comicpress->comicpress_options['layout']]['Sidebars'])) { }
foreach (explode(",", $layouts[$comicpress->comicpress_options['layout']]['Sidebars']) as $sidebar) { }
$sidebar = trim($sidebar);
register_sidebar($sidebar); function comicpress_init() {
} global $post, $comicpress;
}
} if (!empty($post)) {
} if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) {
$comicpress->setup_multicomic_partial_paths($post->ID);
function comicpress_init() { }
global $post, $comicpress; }
if (!empty($post)) { $comicpress->partial_paths[] = get_template_directory() . '/partials';
if (in_comic_category() && $comicpress->is_multicomic() && !is_index()) { }
$comicpress->setup_multicomic_partial_paths($post->ID);
} function comicpress_get_header() {
} get_header();
}
$comicpress->partial_paths[] = get_template_directory() . '/partials';
} function include_partial($partials = '') {
global $comicpress, $post, $nav_comics;
function comicpress_get_header() {
get_header(); if (!is_array($partials)) { $partials = func_get_args(); }
}
$content = $target = null;
function include_partial($partials = '') {
global $comicpress, $post, $nav_comics; if (($result = $comicpress->get_options_partial($partials)) !== false) {
list($target, $code) = $result;
if (!is_array($partials)) { $partials = func_get_args(); } ob_start(); eval(' ?>' . $code . '<?php '); $content = ob_get_clean();
} else {
$content = $target = null; $target = $comicpress->get_partial_path($partials);
if (($result = $comicpress->get_options_partial($partials)) !== false) { if ($target !== false) {
list($target, $code) = $result; ob_start(); include($target); $content = ob_get_clean();
ob_start(); eval(' ?>' . $code . '<?php '); $content = ob_get_clean(); }
} else {
$target = $comicpress->get_partial_path($partials); $target = str_replace(".inc", "", $target);
}
if ($target !== false) {
ob_start(); include($target); $content = ob_get_clean(); if (!empty($target) && !empty($content)) {
} echo apply_filters("comicpress_partial", $content, $target);
}
$target = str_replace(".inc", "", $target); }
}
function in_comic_category() {
if (!empty($target) && !empty($content)) { global $post, $comicpress;
echo apply_filters("comicpress_partial", $content, $target);
} return $comicpress->in_comic_category($post->ID);
} }
function in_comic_category() { /**
global $post, $comicpress; * Display the list of Storyline categories.
*/
return $comicpress->in_comic_category($post->ID); function comicpress_list_storyline_categories($args = "") {
} global $category_tree;
/** $defaults = array(
* Display the list of Storyline categories. 'style' => 'list', 'title_li' => __('Storyline')
*/ );
function comicpress_list_storyline_categories($args = "") {
global $category_tree; $r = wp_parse_args($args, $defaults);
$defaults = array( extract($r);
'style' => 'list', 'title_li' => __('Storyline')
); $categories_by_id = get_all_category_objects_by_id();
$r = wp_parse_args($args, $defaults); $output = '';
if ($style == "list") { $output .= '<li class="categories storyline">'; }
extract($r); if ($title_li && ($style == "list")) { $output .= $title_li; }
if ($style == "list") { $output .= "<ul>"; }
$categories_by_id = get_all_category_objects_by_id(); $current_depth = 0;
foreach ($category_tree as $node) {
$output = ''; $parts = explode("/", $node);
if ($style == "list") { $output .= '<li class="categories storyline">'; } $category_id = end($parts);
if ($title_li && ($style == "list")) { $output .= $title_li; } $target_depth = count($parts) - 2;
if ($style == "list") { $output .= "<ul>"; } if ($target_depth > $current_depth) {
$current_depth = 0; $output .= str_repeat("<li><ul>", ($target_depth - $current_depth));
foreach ($category_tree as $node) { }
$parts = explode("/", $node); if ($target_depth < $current_depth) {
$category_id = end($parts); $output .= str_repeat("</ul></li>", ($current_depth - $target_depth));
$target_depth = count($parts) - 2; }
if ($target_depth > $current_depth) { $output .= '<li><a href="' . get_category_link($category_id) . '">';
$output .= str_repeat("<li><ul>", ($target_depth - $current_depth)); $output .= $categories_by_id[$category_id]->cat_name;
} $output .= "</a></li>";
if ($target_depth < $current_depth) { $current_depth = $target_depth;
$output .= str_repeat("</ul></li>", ($current_depth - $target_depth)); }
} if ($current_depth > 0) {
$output .= '<li><a href="' . get_category_link($category_id) . '">'; $output .= str_repeat("</ul></li>", $current_depth);
$output .= $categories_by_id[$category_id]->cat_name; }
$output .= "</a></li>"; if ($style == "list") { $output .= "</ul></li>"; }
$current_depth = $target_depth; echo $output;
} }
if ($current_depth > 0) {
$output .= str_repeat("</ul></li>", $current_depth); /**
} * Display the comic transcript
if ($style == "list") { $output .= "</ul></li>"; } * Transcript must be entered into a custom field named "transcript"
echo $output; * @param string $displaymode, "raw" (straight from the field), "br" (includes html line breaks), "styled" (fully css styled with JavaScript expander)
} */
function the_transcript($displaymode = 'raw') {
/** $transcript = get_post_meta( get_the_ID(), "transcript", true );
* Display the comic transcript switch ($displaymode) {
* Transcript must be entered into a custom field named "transcript" case "raw":
* @param string $displaymode, "raw" (straight from the field), "br" (includes html line breaks), "styled" (fully css styled with JavaScript expander) echo $transcript;
*/ break;
function the_transcript($displaymode = 'raw') { case "br":
$transcript = get_post_meta( get_the_ID(), "transcript", true ); echo nl2br($transcript);
switch ($displaymode) { break;
case "raw": case "styled":
echo $transcript; if (!empty($transcript)) { ?>
break; <script type='text/javascript'>
case "br": <!--
echo nl2br($transcript); function toggle_expander(id) {
break; var e = document.getElementById(id);
case "styled": if(e.style.height == 'auto')
if (!empty($transcript)) { ?> e.style.height = '1px';
<script type='text/javascript'> else
<!-- e.style.height = 'auto';
function toggle_expander(id) { }
var e = document.getElementById(id); //-->
if(e.style.height == 'auto') </script>
e.style.height = '1px'; <div class="transcript-border"><div id="transcript"><a href="javascript:toggle_expander('transcript-content');" class="transcript-title">&darr; Transcript</a><div id="transcript-content"><?php echo nl2br($transcript); ?><br /><br /></div></div></div>
else <script type='text/javascript'>
e.style.height = 'auto'; <!--
} document.getElementById('transcript-content').style.height = '1px';
//--> //-->
</script> </script><?php
<div class="transcript-border"><div id="transcript"><a href="javascript:toggle_expander('transcript-content');" class="transcript-title">&darr; Transcript</a><div id="transcript-content"><?php echo nl2br($transcript); ?><br /><br /></div></div></div> }
<script type='text/javascript'> break;
<!-- }
document.getElementById('transcript-content').style.height = '1px'; }
//-->
</script><?php // Register Sidebar and Define Widgets
}
break; function widget_comicpress_latest_comics() { ?>
} <li>
} <h2>Latest Comics</h2>
<ul>
// Register Sidebar and Define Widgets <?php global $post;
$latestcomics = get_posts('numberposts=5&category='.get_all_comic_categories_as_cat_string());
function widget_comicpress_latest_comics() { ?> foreach($latestcomics as $post) : ?>
<li> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<h2>Latest Comics</h2> <?php endforeach; ?>
<ul> </ul>
<?php global $post; </li>
$latestcomics = get_posts('numberposts=5&category='.get_all_comic_categories_as_cat_string()); <?php } if ( function_exists('register_sidebar_widget') )
foreach($latestcomics as $post) : ?> register_sidebar_widget(__('Latest Comics'), 'widget_comicpress_latest_comics');
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?> function widget_comicpress_random_comic() { ?>
</ul> <li>
</li> <h2><a href="?randomcomic"><span class="random-comic-icon">?</span> Random Comic</a></h2>
<?php } if ( function_exists('register_sidebar_widget') ) </li>
register_sidebar_widget(__('Latest Comics'), 'widget_comicpress_latest_comics'); <?php } if ( function_exists('register_sidebar_widget') )
register_sidebar_widget(__('Random Comic'), 'widget_comicpress_random_comic');
function widget_comicpress_random_comic() { ?>
<li> function widget_comicpress_archive_dropdown() { ?>
<h2><a href="?randomcomic"><span class="random-comic-icon">?</span> Random Comic</a></h2> <li class="archive-dropdown-wrap">
</li> <select name="archive-dropdown" class="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<?php } if ( function_exists('register_sidebar_widget') ) <option value=""><?php echo attribute_escape(__('Archives...')); ?></option>
register_sidebar_widget(__('Random Comic'), 'widget_comicpress_random_comic'); <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>
</li>
function widget_comicpress_archive_dropdown() { ?> <?php } if ( function_exists('register_sidebar_widget') )
<li class="archive-dropdown-wrap"> register_sidebar_widget(__('Archive Dropdown'), 'widget_comicpress_archive_dropdown');
<select name="archive-dropdown" class="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php echo attribute_escape(__('Archives...')); ?></option> ?>
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>
</li>
<?php } if ( function_exists('register_sidebar_widget') )
register_sidebar_widget(__('Archive Dropdown'), 'widget_comicpress_archive_dropdown');
?>