Part 2 of the configoptions.php addition and revamp removal of the comicpress-config.php

Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
This commit is contained in:
Philip M. Hofer (Frumph) 2009-12-31 14:57:50 -08:00
parent 94d7cdbc02
commit 0d25e953c9
3 changed files with 151 additions and 15 deletions

View File

@ -179,6 +179,26 @@ function comicpress_admin() {
$tab = 'buyprint'; $tab = 'buyprint';
update_option('comicpress_options',$comicpress_options); update_option('comicpress_options',$comicpress_options);
} }
if ($_REQUEST['action'] == 'comicpress_save_config') {
foreach (array(
'comiccat',
'blogcat',
'comic_folder',
'rss_comic_folder',
'archive_comic_folder',
'mini_comic_folder',
'archive_comic_width',
'rss_comic_width',
'mini_comic_width',
'blog_postcount'
) as $key) {
$comicpress_options['comicpress_config'][$key] = wp_filter_nohtml_kses($_REQUEST[$key]);
}
$tab = 'config';
update_option('comicpress_options',$comicpress_options);
}
if ($tab) { if ($tab) {
?> ?>
@ -186,7 +206,7 @@ function comicpress_admin() {
<script>function hidemessage() { document.getElementById('message').style.display = 'none'; }</script> <script>function hidemessage() { document.getElementById('message').style.display = 'none'; }</script>
<?php } <?php }
} }
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'comicpress_reset') { if ($_REQUEST['action'] == 'comicpress_reset') {
delete_option('comicpress_options'); delete_option('comicpress_options');
$comicpress_options = comicpress_load_options(); $comicpress_options = comicpress_load_options();
?> ?>

View File

@ -43,20 +43,12 @@ function __comicpress_widgets_init() {
} }
function __comicpress_init() { function __comicpress_init() {
global $comicpress_options, $__comicpress_handlable_classes, $comiccat, $blogcat, global $comicpress_options, $__comicpress_handlable_classes;
$comic_folder, $rss_comic_folder, $archive_comic_folder, $mini_comic_folder, $archive_comic_width,
$rss_comic_width, $blog_postcount;
$comicpress_options = array(); $comicpress_options = array();
// Check if the $comicpress_options exist, if not set defaults // Check if the $comicpress_options exist, if not set defaults
$comicpress_options = comicpress_load_options(); $comicpress_options = comicpress_load_options();
if (file_exists(get_template_directory() . '/comicpress-config.php')) {
include(get_template_directory() . '/comicpress-config.php');
} else {
extract($comicpress_options['comicpress_config']);
}
// xili-language plugin check // xili-language plugin check
if (class_exists('xili_language')) { if (class_exists('xili_language')) {
@ -106,7 +98,9 @@ add_action('widgets_init', '__comicpress_widgets_init');
add_action('init', '__comicpress_init'); add_action('init', '__comicpress_init');
function comicpress_load_options() { function comicpress_load_options() {
global $comicpress_options; global $comicpress_options, $comiccat, $blogcat, $comic_folder, $rss_comic_folder,
$archive_comic_folder, $mini_comic_folder, $archive_comic_width,
$rss_comic_width, $blog_postcount;
$comicpress_options = get_option('comicpress_options'); $comicpress_options = get_option('comicpress_options');
if (empty($comicpress_options)) { if (empty($comicpress_options)) {
@ -216,6 +210,13 @@ function comicpress_load_options() {
// update_option('comicpress_options', $comicpress_options); // update_option('comicpress_options', $comicpress_options);
} }
$comicpress_options['comicpress_version'] = '2.9.0.9'; $comicpress_options['comicpress_version'] = '2.9.0.9';
// if (file_exists(get_template_directory() . '/comicpress-config.php')) {
// include(get_template_directory() . '/comicpress-config.php');
// } else {
extract($comicpress_options['comicpress_config']);
// }
update_option('comicpress_options', $comicpress_options); update_option('comicpress_options', $comicpress_options);
return $comicpress_options; return $comicpress_options;
} }

View File

@ -6,17 +6,19 @@
<div id="comicpress-options"> <div id="comicpress-options">
<table class="widefat"> <table class="widefat">
<thead> <thead>
<tr> <tr>
<th colspan="2"><?php _e('Configuration','comicpress'); ?></th> <th colspan="5"><?php _e('Configuration','comicpress'); ?></th>
</tr> </tr>
</thead> </thead>
<tr class="alternate"> <tr class="alternate">
<th scope="row"> <th scope="row">
<label for="comiccat"><?php _e('Comic Category','comicpress'); ?></label> <label for="comiccat"><?php _e('Comic Category','comicpress'); ?></label>
<?php <?php
global $comiccat; $comiccat = $comicpress_options['comicpress_config']['comiccat'];
$select = wp_dropdown_categories('show_option_none=Select category&show_count=0&orderby=name&echo=0&selected='.$comiccat); $select = wp_dropdown_categories('show_option_all=Select category&hide_empty=0&show_count=0&orderby=name&echo=0&selected='.$comiccat);
$select = preg_replace('#<select([^>]*)>#', '<select name="comiccat" id="comicccat">', $select); $select = preg_replace('#<select([^>]*)>#', '<select name="comiccat" id="comicccat">', $select);
echo $select; echo $select;
?> ?>
@ -25,6 +27,119 @@
<?php _e('The category that is designated for the primary comic category.','comicpress'); ?> <?php _e('The category that is designated for the primary comic category.','comicpress'); ?>
</td> </td>
</tr> </tr>
<tr>
<th scope="row">
<label for="comiccat"><?php _e('Blog Category','comicpress'); ?></label>
<?php
$blogcat = $comicpress_options['comicpress_config']['blogcat'];
$select = wp_dropdown_categories('show_option_all=Select category&hide_empty=0&show_count=0&orderby=name&echo=0&selected='.$blogcat);
$select = preg_replace('#<select([^>]*)>#', '<select name="blogcat" id="blogcat">', $select);
echo $select;
?>
</th>
<td>
<?php _e('The primary blog category.','comicpress'); ?>
</td>
</tr>
<?php
$dirs_to_search = array_unique(array(ABSPATH));
$directories = array();
foreach ($dirs_to_search as $dir) { $directories = array_merge($directories,glob("${dir}/*")); }
$current_directory = $comicpress_options['comicpress_config']['comic_folder'];
?>
<tr class="alternate">
<th scope="row"><label for="comic_folder"><?php _e('Comic Folder','comicpress'); ?></label>
<select name="comic_folder" id="comic_folder">
<?php
foreach ($directories as $dirs) {
if (is_dir($dirs)) {
$dir_name = basename($dirs); ?>
<option class="level-0" value="<?php echo $dir_name; ?>" <?php if ($current_directory == $dir_name) { ?>selected="selected"<?php } ?>><?php echo $dir_name; ?></option>
<?php }
}
?>
</select>
</th>
<td>
<?php _e('Choose a directory to get the original sized comics from.','comicpress'); ?>
</td>
</tr>
<?php
$current_directory = $comicpress_options['comicpress_config']['rss_comic_folder'];
?>
<tr>
<th scope="row"><label for="rss_comic_folder"><?php _e('RSS Thumbnail Folder','comicpress'); ?></label>
<select name="rss_comic_folder" id="rss_comic_folder">
<?php
foreach ($directories as $dirs) {
if (is_dir($dirs)) {
$dir_name = basename($dirs); ?>
<option class="level-0" value="<?php echo $dir_name; ?>" <?php if ($current_directory == $dir_name) { ?>selected="selected"<?php } ?>><?php echo $dir_name; ?></option>
<?php }
}
?>
</select>
</th>
<td>
<?php _e('Choose a directory to get the RSS thumbnails from.','comicpress'); ?>
</td>
</tr>
<?php
$current_directory = $comicpress_options['comicpress_config']['archive_comic_folder'];
?>
<tr class="alternate">
<th scope="row"><label for="archive_comic_folder"><?php _e('Archive Thumbnail Folder','comicpress'); ?></label>
<select name="archive_comic_folder" id="archive_comic_folder">
<?php
foreach ($directories as $dirs) {
if (is_dir($dirs)) {
$dir_name = basename($dirs); ?>
<option class="level-0" value="<?php echo $dir_name; ?>" <?php if ($current_directory == $dir_name) { ?>selected="selected"<?php } ?>><?php echo $dir_name; ?></option>
<?php }
}
?>
</select>
</th>
<td>
<?php _e('Choose a directory to get the ARCHIVE/SEARCH thumbnails from.','comicpress'); ?>
</td>
</tr>
<?php
$current_directory = $comicpress_options['comicpress_config']['mini_comic_folder'];
?>
<tr>
<th scope="row"><label for="mini_comic_folder"><?php _e('Mini Thumbnail Folder','comicpress'); ?></label>
<select name="mini_comic_folder" id="mini_comic_folder">
<?php
foreach ($directories as $dirs) {
if (is_dir($dirs)) {
$dir_name = basename($dirs); ?>
<option class="level-0" value="<?php echo $dir_name; ?>" <?php if ($current_directory == $dir_name) { ?>selected="selected"<?php } ?>><?php echo $dir_name; ?></option>
<?php }
}
?>
</select>
</th>
<td>
<?php _e('Choose a directory to get the MINI thumbnails from. (for archive-comic-list, etc.)','comicpress'); ?>
</td>
</tr>
</table> </table>
</div> </div>
@ -33,7 +148,7 @@
<div id="major-publishing-actions"> <div id="major-publishing-actions">
<div id="publishing-action"> <div id="publishing-action">
<input name="comicpress_save_config" type="submit" class="button-primary" value="Save Settings" /> <input name="comicpress_save_config" type="submit" class="button-primary" value="Save Settings" />
<input type="hidden" name="action" value="comicpress_save_members" /> <input type="hidden" name="action" value="comicpress_save_config" />
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>