Adjusted to work with subdirectory installations of wordpress.

Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
This commit is contained in:
Philip M. Hofer (Frumph) 2009-10-12 07:32:01 -07:00
parent 661cf0eda3
commit c7d630eaf5
5 changed files with 75 additions and 58 deletions

View File

@ -410,13 +410,20 @@ function get_comic_path($folder = 'comic', $override_post = null, $filter = 'def
$post_date = mysql2date(CP_DATE_FORMAT, $post_to_use->post_date); $post_date = mysql2date(CP_DATE_FORMAT, $post_to_use->post_date);
$filter_with_date = str_replace('{date}', $post_date, $filter_to_use); $filter_with_date = str_replace('{date}', $post_date, $filter_to_use);
$cwd = get_stylesheet_directory();
if ($cwd !== false) {
// Strip the wp-admin part and just get to the root.
$root_path = preg_replace('#[\\/]wp-(admin|content).*#', '', $cwd);
}
$results = array(); $results = array();
/* have to use root_path to get subdirectory installation directories */
if (count($results = glob("${folder_to_use}/${filter_with_date}")) > 0) { if (count($results = glob("${root_path}/${folder_to_use}/${filter_with_date}")) > 0) {
if (!empty($wpmu_version)) { if (!empty($wpmu_version)) {
$comic = reset($results); $comic = reset($results);
$comic = $folder_to_use . '/'. basename($comic);
if ($wpmu_path !== false) { $comic = str_replace($wpmu_path, "files", $comic); } if ($wpmu_path !== false) { $comic = str_replace($wpmu_path, "files", $comic); }
return $comic; return $comic;
} }
@ -424,11 +431,14 @@ function get_comic_path($folder = 'comic', $override_post = null, $filter = 'def
if (!empty($multi)) { if (!empty($multi)) {
return $results; return $results;
} else { } else {
return reset($results); /* clear the root path */
$comic = reset($results);
$comic = $folder_to_use .'/'. basename($comic);
return $comic;
} }
} }
$comic_pathfinding_errors[] = sprintf(__("Unable to find the file in the <strong>%s</strong> folder that matched the pattern <strong>%s</strong>. Check your WordPress and ComicPress settings.", 'comicpress'), $folder, $filter_with_date); echo $comic_pathfinding_errors[] = sprintf(__("Unable to find the file in the <strong>%s</strong> folder that matched the pattern <strong>%s</strong>. Check your WordPress and ComicPress settings.", 'comicpress'), $folder_to_use, $filter_with_date);
return false; return false;
} }
@ -442,13 +452,14 @@ function get_comic_path($folder = 'comic', $override_post = null, $filter = 'def
*/ */
function get_comic_url($folder = 'comic', $override_post = null, $filter = 'default') { function get_comic_url($folder = 'comic', $override_post = null, $filter = 'default') {
if (($result = get_comic_path($folder, $override_post, $filter)) !== false) { if (($result = get_comic_path($folder, $override_post, $filter)) !== false) {
return get_option('home') . '/' . $result; return get_bloginfo('wpurl') . '/' . $result;
} else { } else {
if (($result = get_comic_path('comic', $override_post, $filter)) !== false) { if (($result = get_comic_path('comic', $override_post, $filter)) !== false) {
return get_option('home') . '/' . $result; $basecomic = basename($result);
return get_bloginfo('wpurl') . '/' . $result;
} }
} }
return false; return $result;
} }
/** /**

View File

@ -830,13 +830,25 @@ ul.children {
.sidebar ul { .sidebar ul {
margin: 0; margin: 0;
padding: 0 0 0 14px;
list-style: none; list-style: none;
padding: 0;
} }
.sidebar ul li ul li { .sidebar ul li {
margin: 0; margin: 0;
padding-left: 14px; padding: 0;
text-align: left;
list-style: none;
}
.sidebar ul li ul li {
margin: 0;
padding: 0;
text-align: left;
}
.sidebar li h2 {
margin-top: 15px;
} }
.sidebar .widget { .sidebar .widget {

View File

@ -4,43 +4,42 @@ Widget Name: Control Panel
Widget URI: http://comicpress.org/ Widget URI: http://comicpress.org/
Description: Display an area for login and logout, forgot password and register. Description: Display an area for login and logout, forgot password and register.
Author: Philip M. Hofer (Frumph) Author: Philip M. Hofer (Frumph)
Version: 1.01 Version: 1.02
Author URI: http://webcomicplanet.com/ Author URI: http://webcomicplanet.com/
*/ */
function comicpress_show_control_panel() { function comicpress_show_control_panel() {
global $wpmu_version; ?> global $wpmu_version; ?>
<ul>
<?php if (!is_user_logged_in()) { ?> <?php if (!is_user_logged_in()) { ?>
<li> <form action="<?php bloginfo('wpurl') ?>/wp-login.php" method="post">
<?php if ( get_option('users_can_register') ) { ?> <?php _e('UserName:','comicpress'); ?><br />
<form action="<?php bloginfo('url') ?>/wp-login.php" method="post"> <input type="text" name="log" id="sname" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" /><br /><br />
<?php _e('UserName:','comicpress'); ?><br /> <?php _e('Password:','comicpress'); ?><br />
<input type="text" name="log" id="sname" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" /><br /><br /> <input type="password" name="pwd" id="spassword" size="22" /><br />
<?php _e('Password:','comicpress'); ?><br /> <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label><br />
<input type="password" name="pwd" id="spassword" size="22" /><br /> <br />
<label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label><br /> <button type="submit" class="button"><?php _e('Login','comicpress'); ?></button>
<br /> <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
<button type="submit" class="button"><?php _e('Login','comicpress'); ?></button> </form>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/> <br />
</form> <ul>
<br /> <?php if (!empty($wpmu_version)) { ?>
<?php if (!empty($wpmu_version)) { ?> <li><a href="<?php bloginfo('wpurl') ?>/wp-signup.php"><?php _e('Register','comicpress'); ?></a></li>
<a href="<?php bloginfo('url') ?>/wp-signup.php"><?php _e('Register','comicpress'); ?></a><br /> <?php } else { ?>
<?php } else { ?> <li><a href="<?php bloginfo('wpurl') ?>/wp-register.php"><?php _e('Register','comicpress'); ?></a></li>
<a href="<?php bloginfo('url') ?>/wp-register.php"><?php _e('Register','comicpress'); ?></a><br />
<?php } ?>
<?php } ?> <?php } ?>
<a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword"><?php _e('Recover password','comicpress'); ?></a> <li><a href="<?php bloginfo('wpurl') ?>/wp-login.php?action=lostpassword"><?php _e('Recover password','comicpress'); ?></a></li>
</ul>
<?php } else { ?> <?php } else { ?>
<?php $redirect = '&amp;redirect_to='.urlencode(wp_make_link_relative(get_option('siteurl'))); <ul>
<?php $redirect = '&amp;redirect_to='.urlencode(wp_make_link_relative(get_bloginfo('wpurl')));
$uri = wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' ); ?> $uri = wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' ); ?>
<li><a href="<?php echo $uri; ?>"><?php _e('Logout','comicpress'); ?></a></li> <li><a href="<?php echo $uri; ?>"><?php _e('Logout','comicpress'); ?></a></li>
<?php wp_register(); ?> <?php wp_register(); ?>
<li><a href="/wp-admin/profile.php"><?php _e('Profile','comicpress'); ?></a></li> <li><a href="<?php bloginfo('wpurl'); ?>/wp-admin/profile.php"><?php _e('Profile','comicpress'); ?></a></li>
</ul>
<?php } ?> <?php } ?>
</ul>
<?php <?php
} }

View File

@ -9,21 +9,17 @@ Author URI: http://webcomicplanet.com/
*/ */
function comicpress_latest_comics() { ?> function comicpress_latest_comics() { ?>
<ul> <h2>Latest Comics</h2>
<li> <ul>
<h2>Latest Comics</h2> <?php global $post;
<ul> $latestcomics = get_posts('numberposts=5&category='.get_all_comic_categories_as_cat_string());
<?php global $post; foreach($latestcomics as $post) : ?>
$latestcomics = get_posts('numberposts=5&category='.get_all_comic_categories_as_cat_string()); <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
foreach($latestcomics as $post) : ?> <?php endforeach; ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</li>
</ul> </ul>
<?php <?php
} }
class widget_comicpress_latest_comics extends WP_Widget { class widget_comicpress_latest_comics extends WP_Widget {

View File

@ -26,14 +26,13 @@ class widget_comicpress_show_scheduled_posts extends WP_Widget {
$scheduled_posts = get_posts('post_status=future&numberposts=-1'); $scheduled_posts = get_posts('post_status=future&numberposts=-1');
if (empty($scheduled_posts)) { if (empty($scheduled_posts)) {
echo '<ul><li>None.</li></ul>'; echo '<ul><li>None.</li></ul>';
} else { } else { ?>
foreach($scheduled_posts as $post) : ?> <ul>
<ul> <?php foreach($scheduled_posts as $post) : ?>
<li><span class="scheduled-post-title"><?php echo $post->post_title; ?></span> <li><span class="scheduled-post-date"><?php echo date('m/d/Y',strtotime($post->post_date)); ?></span> <span class="scheduled-post-title"><?php echo $post->post_title; ?></span></li>
<span class="scheduled-post-date"><?php echo date('m/d/Y',strtotime($post->post_date)); ?></span> </li> <?php endforeach; ?>
</ul> </ul>
<?php endforeach; <?php }
}
echo $after_widget; echo $after_widget;
echo '</div>'; echo '</div>';
} }