diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-10-13 11:22:53 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-10-13 11:22:53 +0000 |
commit | eb452d72e52ea6beb876e7a7016d517a7f54e3f1 (patch) | |
tree | dfddf126deae4eb7092c30e6a88646cd47496b3c | |
parent | 3318c3ebfd1c5de95b49a139268db4b42336d478 (diff) | |
download | wordpress-mu-eb452d72e52ea6beb876e7a7016d517a7f54e3f1.tar.gz wordpress-mu-eb452d72e52ea6beb876e7a7016d517a7f54e3f1.tar.xz wordpress-mu-eb452d72e52ea6beb876e7a7016d517a7f54e3f1.zip |
Massive code formatting cleanup and url slash fixing
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@401 7be80a69-a1ef-0310-a953-fb0f7c49ff36
-rw-r--r-- | wp-inst/readme.html | 4 | ||||
-rw-r--r-- | wp-inst/wp-admin/import-b2.php | 4 | ||||
-rw-r--r-- | wp-inst/wp-admin/import-greymatter.php | 2 | ||||
-rw-r--r-- | wp-inst/wp-admin/import-mt.php | 2 | ||||
-rw-r--r-- | wp-inst/wp-admin/import-textpattern.php | 2 | ||||
-rw-r--r-- | wp-inst/wp-admin/import/blogger.php | 2 | ||||
-rw-r--r-- | wp-inst/wp-admin/install.php | 2 | ||||
-rw-r--r-- | wp-inst/wp-admin/setup-config.php | 2 | ||||
-rw-r--r-- | wp-inst/wp-admin/sidebar.php | 4 | ||||
-rw-r--r-- | wp-inst/wp-content/themes/classic/footer.php | 4 | ||||
-rw-r--r-- | wp-inst/wp-content/themes/default/comments-popup.php | 2 | ||||
-rw-r--r-- | wp-inst/wp-content/themes/default/footer.php | 4 | ||||
-rw-r--r-- | wp-inst/wp-includes/template-functions-author.php | 243 | ||||
-rw-r--r-- | wp-inst/wp-includes/template-functions-category.php | 447 | ||||
-rw-r--r-- | wp-inst/wp.php | 4 |
15 files changed, 388 insertions, 340 deletions
diff --git a/wp-inst/readme.html b/wp-inst/readme.html index 88feb37..7fd7eb1 100644 --- a/wp-inst/readme.html +++ b/wp-inst/readme.html @@ -87,7 +87,7 @@ <ul> <li>PHP version <strong>4.1</strong> or higher</li> <li>MySQL version <strong>3.23.23</strong> or higher</li> - <li>... and a link to <a href="http://wordpress.org">http://wordpress.org</a> on your site.</li> + <li>... and a link to <a href="http://wordpress.org/">http://wordpress.org</a> on your site.</li> </ul> <p>WordPress is the official continuation of <a href="http://cafelog.com/">b2/cafélog</a>, which came from Michel V. The work has been continued by the <a href="http://wordpress.org/about/">WordPress developers</a>. If you would like to support WordPress, please consider <a href="http://wordpress.org/donate/">donating</a>. </p> @@ -123,4 +123,4 @@ <p>WordPress is released under the <abbr title="GNU Public License">GPL</abbr> (see <a href="license.txt">license.txt</a>).</p> </body> -</html>
\ No newline at end of file +</html> diff --git a/wp-inst/wp-admin/import-b2.php b/wp-inst/wp-admin/import-b2.php index 9344025..52fb669 100644 --- a/wp-inst/wp-admin/import-b2.php +++ b/wp-inst/wp-admin/import-b2.php @@ -37,7 +37,7 @@ header( 'Content-Type: text/html; charset=utf-8' ); </style> </head> <body> -<h1 id="logo"><a href="http://wordpress.org"><span>WordPress</span></a></h1> +<h1 id="logo"><a href="http://wordpress.org/"><span>WordPress</span></a></h1> <?php switch($step) { @@ -244,4 +244,4 @@ upgrade_all(); ?> </body> -</html>
\ No newline at end of file +</html> diff --git a/wp-inst/wp-admin/import-greymatter.php b/wp-inst/wp-admin/import-greymatter.php index 4d96a82..d46a09d 100644 --- a/wp-inst/wp-admin/import-greymatter.php +++ b/wp-inst/wp-admin/import-greymatter.php @@ -58,7 +58,7 @@ header( 'Content-Type: text/html; charset=utf-8' ); } </style> </head><body> -<h1 id="logo"><a href="http://wordpress.org">WordPress</a></h1> +<h1 id="logo"><a href="http://wordpress.org/">WordPress</a></h1> <?php switch ($action) { diff --git a/wp-inst/wp-admin/import-mt.php b/wp-inst/wp-admin/import-mt.php index b520d4c..54c7f8a 100644 --- a/wp-inst/wp-admin/import-mt.php +++ b/wp-inst/wp-admin/import-mt.php @@ -45,7 +45,7 @@ header( 'Content-Type: text/html; charset=utf-8' ); } </style> </head><body> -<h1 id="logo"><a href="http://wordpress.org">WordPress</a></h1> +<h1 id="logo"><a href="http://wordpress.org/">WordPress</a></h1> <?php switch($step) { diff --git a/wp-inst/wp-admin/import-textpattern.php b/wp-inst/wp-admin/import-textpattern.php index d2f8173..18d1610 100644 --- a/wp-inst/wp-admin/import-textpattern.php +++ b/wp-inst/wp-admin/import-textpattern.php @@ -44,7 +44,7 @@ header( 'Content-Type: text/html; charset=utf-8' ); } </style> </head><body> -<h1 id="logo"><a href="http://wordpress.org">WordPress</a></h1> +<h1 id="logo"><a href="http://wordpress.org/">WordPress</a></h1> <?php switch($step) { diff --git a/wp-inst/wp-admin/import/blogger.php b/wp-inst/wp-admin/import/blogger.php index 82a7d42..922745a 100644 --- a/wp-inst/wp-admin/import/blogger.php +++ b/wp-inst/wp-admin/import/blogger.php @@ -236,7 +236,7 @@ class Blogger_Import { if ( ! count( $blogsary[1] < 1 ) ) die(__('No blogs found for this user.')); $this->import['blogs'] = array(); - $template = '<MainPage><br /><br /><br /><p>'.__('Are you looking for %title%? It is temporarily out of service. Please try again in a few minutes. Meanwhile, discover <a href="http://wordpress.org">a better blogging tool</a>.').'</p><BloggerArchives><a class="archive" href="<$BlogArchiveURL$>"><$BlogArchiveName$></a><br /></BloggerArchives></MainPage><ArchivePage><Blogger><wordpresspost><$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></ArchivePage>'; + $template = '<MainPage><br /><br /><br /><p>'.__('Are you looking for %title%? It is temporarily out of service. Please try again in a few minutes. Meanwhile, discover <a href="http://wordpress.org/">a better blogging tool</a>.').'</p><BloggerArchives><a class="archive" href="<$BlogArchiveURL$>"><$BlogArchiveName$></a><br /></BloggerArchives></MainPage><ArchivePage><Blogger><wordpresspost><$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></ArchivePage>'; foreach ( $blogsary[1] as $key => $id ) { // Define the required Blogger options. $blog_opts = array( diff --git a/wp-inst/wp-admin/install.php b/wp-inst/wp-admin/install.php index 53ba859..814803d 100644 --- a/wp-inst/wp-admin/install.php +++ b/wp-inst/wp-admin/install.php @@ -163,7 +163,7 @@ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, p $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" ); // Default comment -$wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')"); +$wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')"); // First Page diff --git a/wp-inst/wp-admin/setup-config.php b/wp-inst/wp-admin/setup-config.php index da753c1..9cf3402 100644 --- a/wp-inst/wp-admin/setup-config.php +++ b/wp-inst/wp-admin/setup-config.php @@ -48,7 +48,7 @@ header( 'Content-Type: text/html; charset=utf-8' ); </style> </head> <body> -<h1 id="logo"><a href="http://wordpress.org"><span>WordPress</span></a></h1> +<h1 id="logo"><a href="http://wordpress.org/"><span>WordPress</span></a></h1> <?php switch($step) { diff --git a/wp-inst/wp-admin/sidebar.php b/wp-inst/wp-admin/sidebar.php index 51405e0..896359b 100644 --- a/wp-inst/wp-admin/sidebar.php +++ b/wp-inst/wp-admin/sidebar.php @@ -47,7 +47,7 @@ form { </style> </head> <body id="sidebar"> -<h1 id="wphead"><a href="http://wordpress.org" rel="external">WordPress</a></h1> +<h1 id="wphead"><a href="http://wordpress.org/" rel="external">WordPress</a></h1> <form name="post" action="post.php" method="POST"> <div><input type="hidden" name="action" value="post" /> <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" /> @@ -76,4 +76,4 @@ Post: </html> <?php } -?>
\ No newline at end of file +?> diff --git a/wp-inst/wp-content/themes/classic/footer.php b/wp-inst/wp-content/themes/classic/footer.php index b18b022..7c821c2 100644 --- a/wp-inst/wp-content/themes/classic/footer.php +++ b/wp-inst/wp-content/themes/classic/footer.php @@ -3,10 +3,10 @@ <?php get_sidebar(); ?> -<p class="credit"><!--<?php echo $wpdb->num_queries; ?> queries. <?php timer_stop(1); ?> seconds. --> <cite><?php echo sprintf(__("Powered by <a href='http://wordpress.org' title='%s'><strong>WordPress</strong></a>"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></cite></p> +<p class="credit"><!--<?php echo $wpdb->num_queries; ?> queries. <?php timer_stop(1); ?> seconds. --> <cite><?php echo sprintf(__("Powered by <a href='http://wordpress.org/' title='%s'><strong>WordPress</strong></a>"), __("Powered by WordPress, state-of-the-art semantic personal publishing platform.")); ?></cite></p> </div> <?php wp_footer(); ?> </body> -</html>
\ No newline at end of file +</html> diff --git a/wp-inst/wp-content/themes/default/comments-popup.php b/wp-inst/wp-content/themes/default/comments-popup.php index f01e3eb..980717b 100644 --- a/wp-inst/wp-content/themes/default/comments-popup.php +++ b/wp-inst/wp-content/themes/default/comments-popup.php @@ -99,7 +99,7 @@ if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH <!-- // this is just the end of the motor - don't touch that line either :) --> <?php //} ?> -<p class="credit"><?php timer_stop(1); ?> <cite>Powered by <a href="http://wordpress.org" title="Powered by WordPress, state-of-the-art semantic personal publishing platform"><strong>Wordpress</strong></a></cite></p> +<p class="credit"><?php timer_stop(1); ?> <cite>Powered by <a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform"><strong>Wordpress</strong></a></cite></p> <?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?> <script type="text/javascript"> <!-- diff --git a/wp-inst/wp-content/themes/default/footer.php b/wp-inst/wp-content/themes/default/footer.php index 9ee08e2..1de4c43 100644 --- a/wp-inst/wp-content/themes/default/footer.php +++ b/wp-inst/wp-content/themes/default/footer.php @@ -3,7 +3,7 @@ <div id="footer"> <p> <?php bloginfo('name'); ?> is proudly powered by - <a href="http://wordpress.org">WordPress</a> + <a href="http://wordpress.org/">WordPress</a> <br /><a href="feed:<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a> and <a href="feed:<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>. <!-- <?php echo $wpdb->num_queries; ?> queries. <?php timer_stop(1); ?> seconds. --> @@ -17,4 +17,4 @@ <?php wp_footer(); ?> </body> -</html>
\ No newline at end of file +</html> diff --git a/wp-inst/wp-includes/template-functions-author.php b/wp-inst/wp-includes/template-functions-author.php index 890e87b..266db76 100644 --- a/wp-inst/wp-includes/template-functions-author.php +++ b/wp-inst/wp-includes/template-functions-author.php @@ -1,56 +1,65 @@ <?php function get_the_author($idmode = '') { - global $authordata; - return apply_filters('the_author', $authordata->display_name); + global $authordata; + return apply_filters('the_author', $authordata->display_name); } function the_author($idmode = '', $echo = true) { - if ($echo) echo get_the_author($idmode); + if ( $echo ) + echo get_the_author($idmode); return get_the_author($idmode); } function get_the_author_description() { - global $authordata; - return $authordata->user_description; + global $authordata; + return $authordata->user_description; } function the_author_description() { - echo get_the_author_description(); + echo get_the_author_description(); } function get_the_author_login() { - global $id,$authordata; return $authordata->user_login; + global $authordata; + return $authordata->user_login; } + function the_author_login() { - echo get_the_author_login(); + echo get_the_author_login(); } function get_the_author_firstname() { - global $id,$authordata; return $authordata->first_name; + global $authordata; + return $authordata->first_name; } function the_author_firstname() { - echo get_the_author_firstname(); + echo get_the_author_firstname(); } function get_the_author_lastname() { - global $id,$authordata; return $authordata->last_name; + global $authordata; + return $authordata->last_name; } + function the_author_lastname() { - echo get_the_author_lastname(); + echo get_the_author_lastname(); } function get_the_author_nickname() { - global $id,$authordata; return $authordata->nickname; + global $authordata; + return $authordata->nickname; } + function the_author_nickname() { - echo get_the_author_nickname(); + echo get_the_author_nickname(); } function get_the_author_ID() { - global $id,$authordata; return $authordata->ID; + global $authordata; + return $authordata->ID; } function the_author_ID() { - echo get_the_author_id(); + echo get_the_author_id(); } function get_the_author_email() { @@ -63,149 +72,163 @@ function the_author_email() { } function get_the_author_url() { - global $id,$authordata; return $authordata->user_url; + global $authordata; + return $authordata->user_url; } + function the_author_url() { - echo get_the_author_url(); + echo get_the_author_url(); } function get_the_author_icq() { - global $id,$authordata; return $authordata->icq; + global $authordata; + return $authordata->icq; } + function the_author_icq() { - echo get_the_author_icq(); + echo get_the_author_icq(); } function get_the_author_aim() { - global $id,$authordata; return str_replace(' ', '+', $authordata->aim); + global $authordata; + return str_replace(' ', '+', $authordata->aim); } + function the_author_aim() { - echo get_the_author_aim(); + echo get_the_author_aim(); } function get_the_author_yim() { - global $id,$authordata; return $authordata->yim; + global $authordata; + return $authordata->yim; } + function the_author_yim() { - echo get_the_author_yim(); + echo get_the_author_yim(); } function get_the_author_msn() { - global $id,$authordata; return $authordata->msn; + global $authordata; + return $authordata->msn; } + function the_author_msn() { - echo get_the_author_msn(); + echo get_the_author_msn(); } function get_the_author_posts() { - global $id,$post; - $posts=get_usernumposts($post->post_author); + global $post; + $posts = get_usernumposts($post->post_author); return $posts; } + function the_author_posts() { - echo get_the_author_posts(); + echo get_the_author_posts(); } /* the_author_posts_link() requires no get_, use get_author_link() */ function the_author_posts_link($idmode='') { - global $id, $authordata; + global $authordata; - echo '<a href="' . get_author_link(0, $authordata->ID, $authordata->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars(the_author($idmode, false))) . '">' . the_author($idmode, false) . '</a>'; + echo '<a href="' . get_author_link(0, $authordata->ID, $authordata->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars(the_author($idmode, false))) . '">' . the_author($idmode, false) . '</a>'; } - function get_author_link($echo = false, $author_id, $author_nicename) { global $wpdb, $wp_rewrite, $post, $cache_userdata; - $auth_ID = $author_id; - $link = $wp_rewrite->get_author_permastruct(); - - if (empty($link)) { - $file = get_settings('home') . '/'; - $link = $file . '?author=' . $auth_ID; - } else { - if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->user_nicename; - $link = str_replace('%author%', $author_nicename, $link); - $link = get_settings('home') . trailingslashit($link); - } - - $link = apply_filters('author_link', $link, $author_id, $author_nicename); - if ($echo) echo $link; - return $link; + $auth_ID = $author_id; + $link = $wp_rewrite->get_author_permastruct(); + + if ( empty($link) ) { + $file = get_settings('home') . '/'; + $link = $file . '?author=' . $auth_ID; + } else { + if ( '' == $author_nicename ) + $author_nicename = $cache_userdata[$author_id]->user_nicename; + $link = str_replace('%author%', $author_nicename, $link); + $link = get_settings('home') . trailingslashit($link); + } + + $link = apply_filters('author_link', $link, $author_id, $author_nicename); + + if ( $echo ) + echo $link; + return $link; } function wp_list_authors($args = '') { parse_str($args, $r); - if (!isset($r['optioncount'])) $r['optioncount'] = false; - if (!isset($r['exclude_admin'])) $r['exclude_admin'] = true; - if (!isset($r['show_fullname'])) $r['show_fullname'] = false; - if (!isset($r['hide_empty'])) $r['hide_empty'] = true; - if (!isset($r['feed'])) $r['feed'] = ''; - if (!isset($r['feed_image'])) $r['feed_image'] = ''; + + if ( !isset($r['optioncount']) ) + $r['optioncount'] = false; + if ( !isset($r['exclude_admin']) ) + $r['exclude_admin'] = true; + if ( !isset($r['show_fullname']) ) + $r['show_fullname'] = false; + if ( !isset($r['hide_empty']) ) + $r['hide_empty'] = true; + if ( !isset($r['feed']) ) + $r['feed'] = ''; + if ( !isset($r['feed_image']) ) + $r['feed_image'] = ''; list_authors($r['optioncount'], $r['exclude_admin'], $r['show_fullname'], $r['hide_empty'], $r['feed'], $r['feed_image']); } function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { - global $wpdb; - - $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"; - $authors = $wpdb->get_results($query); + global $wpdb; + $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"; + $authors = $wpdb->get_results($query); - foreach($authors as $author) { + foreach ( $authors as $author ) { $author = get_userdata( $author->ID ); - $posts = get_usernumposts($author->ID); - $name = $author->nickname; - - if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) { - $name = "$author->first_name $author->last_name"; - } - - if (! ($posts == 0 && $hide_empty)) echo "<li>"; - if ($posts == 0) { - if ( !$hide_empty ) + $posts = get_usernumposts($author->ID); + $name = $author->nickname; + + if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) + $name = "$author->first_name $author->last_name"; + + if ( !($posts == 0 && $hide_empty) ) + echo "<li>"; + if ( $posts == 0 ) { + if ( !$hide_empty ) $link = $name; - } else { - $link = '<a href="' . get_author_link(0, $author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars($author->display_name)) . '">' . $name . '</a>'; - - if ( (! empty($feed_image)) || (! empty($feed)) ) { - - $link .= ' '; - - if (empty($feed_image)) { - $link .= '('; - } - - $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"'; - - if (! empty($feed)) { - $title = ' title="' . $feed . '"'; - $alt = ' alt="' . $feed . '"'; - $name = $feed; - $link .= $title; - } - - $link .= '>'; - - if (! empty($feed_image)) { - $link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />'; - } else { - $link .= $name; - } - - $link .= '</a>'; - - if (empty($feed_image)) { - $link .= ')'; - } - } - - if ($optioncount) { - $link .= ' ('. $posts . ')'; - } - } - - if (! ($posts == 0 && $hide_empty)) echo "$link</li>"; - } + } else { + $link = '<a href="' . get_author_link(0, $author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars($author->display_name)) . '">' . $name . '</a>'; + + if ( (! empty($feed_image)) || (! empty($feed)) ) { + $link .= ' '; + if (empty($feed_image)) + $link .= '('; + $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"'; + + if ( !empty($feed) ) { + $title = ' title="' . $feed . '"'; + $alt = ' alt="' . $feed . '"'; + $name = $feed; + $link .= $title; + } + + $link .= '>'; + + if ( !empty($feed_image) ) + $link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />'; + else + $link .= $name; + + $link .= '</a>'; + + if ( empty($feed_image) ) + $link .= ')'; + } + + if ( $optioncount ) + $link .= ' ('. $posts . ')'; + + } + + if ( !($posts == 0 && $hide_empty) ) + echo "$link</li>"; + } } ?> diff --git a/wp-inst/wp-includes/template-functions-category.php b/wp-inst/wp-includes/template-functions-category.php index 9a4a208..1f8e0e5 100644 --- a/wp-inst/wp-includes/template-functions-category.php +++ b/wp-inst/wp-includes/template-functions-category.php @@ -1,17 +1,17 @@ <?php function get_the_category($id = false) { - global $post, $category_cache; +global $post, $category_cache; if ( !$id ) $id = $post->ID; - if ( ! isset($category_cache[$id]) ) + if ( !isset($category_cache[$id]) ) update_post_category_cache($id); $categories = $category_cache[$id]; - if (!empty($categories)) + if ( !empty($categories) ) sort($categories); else $categories = array(); @@ -30,7 +30,7 @@ function get_category_link($category_id) { $category = &get_category($category_id); $category_nicename = $category->category_nicename; - if ($parent = $category->category_parent) + if ( $parent = $category->category_parent ) $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/'; $catlink = str_replace('%category%', $category_nicename, $catlink); @@ -40,60 +40,60 @@ function get_category_link($category_id) { } function get_the_category_list($separator = '', $parents='') { - $categories = get_the_category(); - if (empty($categories)) { - return apply_filters('the_category', __('Uncategorized'), $separator, $parents); - } - - $thelist = ''; - if ('' == $separator) { - $thelist .= '<ul class="post-categories">'; - foreach ($categories as $category) { - $category->cat_name = $category->cat_name; - $thelist .= "\n\t<li>"; - switch(strtolower($parents)) { - case 'multiple': - if ($category->category_parent) { - $thelist .= get_category_parents($category->category_parent, TRUE); - } - $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; - break; - case 'single': - $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">'; - if ($category->category_parent) { - $thelist .= get_category_parents($category->category_parent, FALSE); - } - $thelist .= $category->cat_name.'</a></li>'; - break; - case '': - default: - $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; - } - } - $thelist .= '</ul>'; - } else { - $i = 0; - foreach ($categories as $category) { - $category->cat_name = $category->cat_name; - if (0 < $i) $thelist .= $separator . ' '; - switch(strtolower($parents)) { - case 'multiple': - if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, TRUE); - $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; - break; - case 'single': - $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'; - if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, FALSE); - $thelist .= "$category->cat_name</a>"; - break; - case '': - default: - $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; - } - ++$i; - } - } - return apply_filters('the_category', $thelist, $separator, $parents); + $categories = get_the_category(); + if (empty($categories)) + return apply_filters('the_category', __('Uncategorized'), $separator, $parents); + + $thelist = ''; + if ( '' == $separator ) { + $thelist .= '<ul class="post-categories">'; + foreach ( $categories as $category ) { + $category->cat_name = $category->cat_name; + $thelist .= "\n\t<li>"; + switch ( strtolower($parents) ) { + case 'multiple': + if ($category->category_parent) + $thelist .= get_category_parents($category->category_parent, TRUE); + $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; + break; + case 'single': + $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">'; + if ($category->category_parent) + $thelist .= get_category_parents($category->category_parent, FALSE); + $thelist .= $category->cat_name.'</a></li>'; + break; + case '': + default: + $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; + } + } + $thelist .= '</ul>'; + } else { + $i = 0; + foreach ( $categories as $category ) { + $category->cat_name = $category->cat_name; + if ( 0 < $i ) + $thelist .= $separator . ' '; + switch ( strtolower($parents) ) { + case 'multiple': + if ( $category->category_parent ) + $thelist .= get_category_parents($category->category_parent, TRUE); + $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; + break; + case 'single': + $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'; + if ( $category->category_parent ) + $thelist .= get_category_parents($category->category_parent, FALSE); + $thelist .= "$category->cat_name</a>"; + break; + case '': + default: + $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; + } + ++$i; + } + } + return apply_filters('the_category', $thelist, $separator, $parents); } function the_category($separator = '', $parents='') { @@ -107,32 +107,34 @@ function get_the_category_by_ID($cat_ID) { } function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){ - $chain = ''; - $parent = &get_category($id); - if ($nicename) { - $name = $parent->category_nicename; - } else { - $name = $parent->cat_name; - } - if ($parent->category_parent) $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); - if ($link) { - $chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator; - } else { - $chain .= $name.$separator; - } - return $chain; + $chain = ''; + $parent = &get_category($id); + + if ( $nicename ) + $name = $parent->category_nicename; + else + $name = $parent->cat_name; + + if ( $parent->category_parent ) + $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); + + if ( $link ) + $chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator; + else + $chain .= $name.$separator; + return $chain; } function get_category_children($id, $before = '/', $after = '') { global $cache_categories; - if ( ! isset($cache_categories)) + if ( !isset($cache_categories) ) update_category_cache(); - + $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy $chain = ''; - foreach ($c_cache as $category){ - if ($category->category_parent == $id){ + foreach ( $c_cache as $category ) { + if ( $category->category_parent == $id ) { $chain .= $before.$category->cat_ID.$after; $chain .= get_category_children($category->cat_ID, $before, $after); } @@ -142,105 +144,131 @@ function get_category_children($id, $before = '/', $after = '') { // Deprecated. function the_category_ID($echo = true) { - // Grab the first cat in the list. - $categories = get_the_category(); - $cat = $categories[0]->cat_ID; - - if ($echo) echo $cat; + // Grab the first cat in the list. + $categories = get_the_category(); + $cat = $categories[0]->cat_ID; - return $cat; + if ( $echo ) + echo $cat; + + return $cat; } // Deprecated. function the_category_head($before='', $after='') { - global $currentcat, $previouscat; - // Grab the first cat in the list. - $categories = get_the_category(); - $currentcat = $categories[0]->category_id; - if ($currentcat != $previouscat) { - echo $before; - echo get_the_category_by_ID($currentcat); - echo $after; - $previouscat = $currentcat; - } + global $currentcat, $previouscat; + // Grab the first cat in the list. + $categories = get_the_category(); + $currentcat = $categories[0]->category_id; + if ( $currentcat != $previouscat ) { + echo $before; + echo get_the_category_by_ID($currentcat); + echo $after; + $previouscat = $currentcat; + } } function category_description($category = 0) { - global $cat; - if (!$category) $category = $cat; - $category = & get_category($category); - return apply_filters('category_description', $category->category_description, $category->cat_ID); + global $cat; + if ( !$category ) + $category = $cat; + $category = & get_category($category); + return apply_filters('category_description', $category->category_description, $category->cat_ID); } // out of the WordPress loop function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', - $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE, - $selected=0, $hide=0) { - global $wpdb; - if (($file == 'blah') || ($file == '')) $file = get_settings('home') . '/'; - if (!$selected) $selected=$cat; - $sort_column = 'cat_'.$sort_column; - - $query = " - SELECT cat_ID, cat_name, category_nicename,category_parent, - COUNT($wpdb->post2cat.post_id) AS cat_count, - DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth - FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id) - LEFT JOIN $wpdb->posts ON (ID = post_id) - WHERE cat_ID > 0 - "; - if ($hide) { - $query .= " AND cat_ID != $hide"; - $query .= get_category_children($hide, " AND cat_ID != "); - } - $query .=" GROUP BY cat_ID"; - if (intval($hide_empty) == 1) $query .= " HAVING cat_count > 0"; - $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; - - $categories = $wpdb->get_results($query); - echo "<select name='cat' class='postform'>\n"; - if (intval($optionall) == 1) { - $all = apply_filters('list_cats', $all); - echo "\t<option value='0'>$all</option>\n"; - } - if (intval($optionnone) == 1) echo "\t<option value='-1'>".__('None')."</option>\n"; - if ($categories) { - foreach ($categories as $category) { - $cat_name = apply_filters('list_cats', $category->cat_name, $category); - echo "\t<option value=\"".$category->cat_ID."\""; - if ($category->cat_ID == $selected) - echo ' selected="selected"'; - echo '>'; - echo $cat_name; - if (intval($optioncount) == 1) echo ' ('.$category->cat_count.')'; - if (intval($optiondates) == 1) echo ' '.$category->lastday.'/'.$category->lastmonth; - echo "</option>\n"; - } - } - echo "</select>\n"; + $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE, + $selected=0, $hide=0) { + global $wpdb; + if ( ($file == 'blah') || ($file == '') ) + $file = get_settings('home') . '/'; + if ( !$selected ) + $selected=$cat; + $sort_column = 'cat_'.$sort_column; + + $query = " + SELECT cat_ID, cat_name, category_nicename,category_parent, + COUNT($wpdb->post2cat.post_id) AS cat_count, + DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth + FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id) + LEFT JOIN $wpdb->posts ON (ID = post_id) + WHERE cat_ID > 0 + "; + if ( $hide ) { + $query .= " AND cat_ID != $hide"; + $query .= get_category_children($hide, " AND cat_ID != "); + } + $query .=" GROUP BY cat_ID"; + if ( intval($hide_empty) == 1 ) + $query .= " HAVING cat_count > 0"; + $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; + + $categories = $wpdb->get_results($query); + echo "<select name='cat' class='postform'>\n"; + if ( intval($optionall) == 1 ) { + $all = apply_filters('list_cats', $all); + echo "\t<option value='0'>$all</option>\n"; + } + if ( intval($optionnone) == 1 ) + echo "\t<option value='-1'>".__('None')."</option>\n"; + if ( $categories ) { + foreach ( $categories as $category ) { + $cat_name = apply_filters('list_cats', $category->cat_name, $category); + echo "\t<option value=\"".$category->cat_ID."\""; + if ( $category->cat_ID == $selected ) + echo ' selected="selected"'; + echo '>'; + echo $cat_name; + if ( intval($optioncount) == 1 ) + echo ' ('.$category->cat_count.')'; + if ( intval($optiondates) == 1 ) + echo ' '.$category->lastday.'/'.$category->lastmonth; + echo "</option>\n"; + } + } + echo "</select>\n"; } // out of the WordPress loop function wp_list_cats($args = '') { parse_str($args, $r); - if (!isset($r['optionall'])) $r['optionall'] = 0; - if (!isset($r['all'])) $r['all'] = 'All'; - if (!isset($r['sort_column'])) $r['sort_column'] = 'ID'; - if (!isset($r['sort_order'])) $r['sort_order'] = 'asc'; - if (!isset($r['file'])) $r['file'] = ''; - if (!isset($r['list'])) $r['list'] = true; - if (!isset($r['optiondates'])) $r['optiondates'] = 0; - if (!isset($r['optioncount'])) $r['optioncount'] = 0; - if (!isset($r['hide_empty'])) $r['hide_empty'] = 1; - if (!isset($r['use_desc_for_title'])) $r['use_desc_for_title'] = 1; - if (!isset($r['children'])) $r['children'] = true; - if (!isset($r['child_of'])) $r['child_of'] = 0; - if (!isset($r['categories'])) $r['categories'] = 0; - if (!isset($r['recurse'])) $r['recurse'] = 0; - if (!isset($r['feed'])) $r['feed'] = ''; - if (!isset($r['feed_image'])) $r['feed_image'] = ''; - if (!isset($r['exclude'])) $r['exclude'] = ''; - if (!isset($r['hierarchical'])) $r['hierarchical'] = true; + if ( !isset($r['optionall'])) + $r['optionall'] = 0; + if ( !isset($r['all'])) + $r['all'] = 'All'; + if ( !isset($r['sort_column']) ) + $r['sort_column'] = 'ID'; + if ( !isset($r['sort_order']) ) + $r['sort_order'] = 'asc'; + if ( !isset($r['file']) ) + $r['file'] = ''; + if ( !isset($r['list']) ) + $r['list'] = true; + if ( !isset($r['optiondates']) ) + $r['optiondates'] = 0; + if ( !isset($r['optioncount']) ) + $r['optioncount'] = 0; + if ( !isset($r['hide_empty']) ) + $r['hide_empty'] = 1; + if ( !isset($r['use_desc_for_title']) ) + $r['use_desc_for_title'] = 1; + if ( !isset($r['children']) ) + $r['children'] = true; + if ( !isset($r['child_of']) ) + $r['child_of'] = 0; + if ( !isset($r['categories']) ) + $r['categories'] = 0; + if ( !isset($r['recurse']) ) + $r['recurse'] = 0; + if ( !isset($r['feed']) ) + $r['feed'] = ''; + if ( !isset($r['feed_image']) ) + $r['feed_image'] = ''; + if ( !isset($r['exclude']) ) + $r['exclude'] = ''; + if ( !isset($r['hierarchical']) ) + $r['hierarchical'] = true; return list_cats($r['optionall'], $r['all'], $r['sort_column'], $r['sort_order'], $r['file'], $r['list'], $r['optiondates'], $r['optioncount'], $r['hide_empty'], $r['use_desc_for_title'], $r['children'], $r['child_of'], $r['categories'], $r['recurse'], $r['feed'], $r['feed_image'], $r['exclude'], $r['hierarchical']); } @@ -248,15 +276,14 @@ function wp_list_cats($args = '') { function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) { global $wpdb, $category_posts; // Optiondates now works - if ('' == $file) { + if ( '' == $file ) $file = get_settings('home') . '/'; - } $exclusions = ''; - if (!empty($exclude)) { + if ( !empty($exclude) ) { $excats = preg_split('/[\s,]+/',$exclude); - if (count($excats)) { - foreach ($excats as $excat) { + if ( count($excats) ) { + foreach ( $excats as $excat ) { $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' '; } } @@ -264,10 +291,10 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $exclusions = apply_filters('list_cats_exclusions', $exclusions ); - if (intval($categories)==0){ + if ( intval($categories) == 0 ) { $sort_column = 'cat_'.$sort_column; - $query = " + $query = " SELECT cat_ID, cat_name, category_nicename, category_description, category_parent FROM $wpdb->categories WHERE cat_ID > 0 $exclusions @@ -275,63 +302,60 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $categories = $wpdb->get_results($query); } - if (!count($category_posts)) { + if ( !count($category_posts) ) { $now = current_time('mysql', 1); $cat_counts = $wpdb->get_results(" SELECT cat_ID, COUNT($wpdb->post2cat.post_id) AS cat_count - FROM $wpdb->categories + FROM $wpdb->categories INNER JOIN $wpdb->post2cat ON (cat_ID = category_id) INNER JOIN $wpdb->posts ON (ID = post_id) WHERE post_status = 'publish' AND post_date_gmt < '$now' $exclusions GROUP BY category_id"); - if (! empty($cat_counts)) { - foreach ($cat_counts as $cat_count) { - if (1 != intval($hide_empty) || $cat_count > 0) { - $category_posts["$cat_count->cat_ID"] = $cat_count->cat_count; - } - } - } + if ( !empty($cat_counts) ) { + foreach ( $cat_counts as $cat_count ) { + if ( 1 != intval($hide_empty) || $cat_count > 0 ) + $category_posts["$cat_count->cat_ID"] = $cat_count->cat_count; + } + } } - + if ( $optiondates ) { $cat_dates = $wpdb->get_results(" SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts - FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories + FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories WHERE post_status = 'publish' AND post_id = ID $exclusions GROUP BY category_id"); - foreach ($cat_dates as $cat_date) { + foreach ( $cat_dates as $cat_date ) { $category_timestamp["$cat_date->category_id"] = $cat_date->ts; } } - + $num_found=0; $thelist = ""; - - foreach ($categories as $category) { - if ((intval($hide_empty) == 0 || isset($category_posts["$category->cat_ID"])) && (!$hierarchical || $category->category_parent == $child_of) ) { + + foreach ( $categories as $category ) { + if ( (intval($hide_empty) == 0 || isset($category_posts["$category->cat_ID"])) && (!$hierarchical || $category->category_parent == $child_of) ) { $num_found++; $link = '<a href="'.get_category_link($category->cat_ID).'" '; - if ($use_desc_for_title == 0 || empty($category->category_description)) { + if ( $use_desc_for_title == 0 || empty($category->category_description) ) $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"'; - } else { + else $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category)) . '"'; - } $link .= '>'; $link .= apply_filters('list_cats', $category->cat_name, $category).'</a>'; if ( (! empty($feed_image)) || (! empty($feed)) ) { - + $link .= ' '; - if (empty($feed_image)) { + if ( empty($feed_image) ) $link .= '('; - } - $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"'; + $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"'; if ( !empty($feed) ) { - $title = ' title="' . $feed . '"'; + $title = ' title="' . $feed . '"'; $alt = ' alt="' . $feed . '"'; $name = $feed; $link .= $title; @@ -339,62 +363,63 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde $link .= '>'; - if (! empty($feed_image)) { + if ( !empty($feed_image) ) $link .= "<img src='$feed_image' $alt$title" . ' />'; - } else { + else $link .= $name; - } - + $link .= '</a>'; - if (empty($feed_image)) { + if (empty($feed_image)) $link .= ')'; - } } - if (intval($optioncount) == 1) { + if ( intval($optioncount) == 1 ) $link .= ' ('.intval($category_posts["$category->cat_ID"]).')'; - } + if ( $optiondates ) { - if ( $optiondates == 1 ) $optiondates = 'Y-m-d'; + if ( $optiondates == 1 ) + $optiondates = 'Y-m-d'; $link .= ' ' . gmdate($optiondates, $category_timestamp["$category->cat_ID"]); } - if ($list) { + + if ( $list ) $thelist .= "\t<li>$link\n"; - } else { + else $thelist .= "\t$link<br />\n"; - } - if ($hierarchical && $children) $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical); - if ($list) $thelist .= "</li>\n"; - } + + if ($hierarchical && $children) + $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical); + if ($list) + $thelist .= "</li>\n"; + } } - if (!$num_found && !$child_of){ - if ($list) { + if ( !$num_found && !$child_of ) { + if ( $list ) { $before = '<li>'; $after = '</li>'; } echo $before . __("No categories") . $after . "\n"; return; } - if ($list && $child_of && $num_found && $recurse) { + if ( $list && $child_of && $num_found && $recurse ) { $pre = "\t\t<ul class='children'>"; $post = "\t\t</ul>\n"; } else { $pre = $post = ''; } $thelist = $pre . $thelist . $post; - if ($recurse) { + if ( $recurse ) return $thelist; - } echo apply_filters('list_cats', $thelist); } function in_category($category) { // Check if the current post is in the given category global $post, $category_cache; $cats = ''; - foreach ($category_cache[$post->ID] as $cat) : + foreach ( $category_cache[$post->ID] as $cat ) { $cats[] = $cat->cat_ID; - endforeach; + } if ( in_array($category, $cats) ) return true; diff --git a/wp-inst/wp.php b/wp-inst/wp.php index 336dd1c..7312a12 100644 --- a/wp-inst/wp.php +++ b/wp-inst/wp.php @@ -37,7 +37,7 @@ require_once('./wp-blog-header.php'); <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?> -<div align="right"><cite>Powered by <a href="http://wordpress.org"><strong>Wordpress</strong></a></cite><br /> +<div align="right"><cite>Powered by <a href="http://wordpress.org/"><strong>Wordpress</strong></a></cite><br /> <br /> <a href="wp-login.php">login</a><br /> <a href="wp-register.php">register</a> @@ -45,4 +45,4 @@ require_once('./wp-blog-header.php'); </body> -</html>
\ No newline at end of file +</html> |