mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Alpha multiple category support.
git-svn-id: http://svn.automattic.com/wordpress/trunk@565 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c1b372eb29
commit
46cb0545c2
@ -416,7 +416,8 @@ function get_permalink($id=false) {
|
||||
'%year%',
|
||||
'%monthnum%',
|
||||
'%day%',
|
||||
'%postname%'
|
||||
'%postname%',
|
||||
'%post_id%'
|
||||
);
|
||||
if (!$id) {
|
||||
if ('' != get_settings('permalink_structure')) {
|
||||
@ -440,7 +441,8 @@ function get_permalink($id=false) {
|
||||
date('Y', $unixtime),
|
||||
date('n', $unixtime),
|
||||
date('j', $unixtime),
|
||||
$idpost->post_name
|
||||
$idpost->post_name,
|
||||
$id
|
||||
);
|
||||
return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
|
||||
} else {
|
||||
@ -1223,26 +1225,54 @@ function posts_nav_link($sep=' :: ', $prelabel='<< Previous Page', $nxtlabel='Ne
|
||||
|
||||
/***** Category tags *****/
|
||||
|
||||
function get_category_link($echo = false, $file='') {
|
||||
global $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename;
|
||||
$cat_ID = $post->post_category;
|
||||
if ($file == '') {
|
||||
$file = "$siteurl/$blogfilename";
|
||||
}
|
||||
if ('http:' != substr($file,0,5)) {
|
||||
$file = "$siteurl/$file";
|
||||
}
|
||||
$link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID;
|
||||
if ($echo)
|
||||
echo($link);
|
||||
return $link;
|
||||
function get_the_category() {
|
||||
global $post, $tablecategories, $tablepost2cat, $wpdb;
|
||||
$categories = $wpdb->get_results("
|
||||
SELECT category_id, cat_name, category_nicename
|
||||
FROM $tablecategories, $tablepost2cat
|
||||
WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID
|
||||
");
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
function the_category() {
|
||||
$category = get_the_category();
|
||||
$category = apply_filters('the_category', $category);
|
||||
echo convert_chars($category, 'html');
|
||||
function get_category_link($echo = false, $category_id) {
|
||||
global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename;
|
||||
$cat_ID = $category_id;
|
||||
$permalink_structure = get_settings('permalink_structure');
|
||||
|
||||
if ('' == $permalink_structure) {
|
||||
$file = "$siteurl/$blogfilename";
|
||||
$link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID;
|
||||
} else {
|
||||
$category_nicename = $wpdb->get_var("SELECT category_nicename FROM $tablecategories WHERE cat_ID = $category_id");
|
||||
// Get any static stuff from the front
|
||||
$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
|
||||
$link = $front . 'category/' . $category_nicename;
|
||||
}
|
||||
|
||||
if ($echo) echo $link;
|
||||
return $link;
|
||||
}
|
||||
|
||||
function the_category($seperator = '') {
|
||||
$categories = get_the_category();
|
||||
if ('' == $seperator) {
|
||||
echo '<ul class="post-categories">';
|
||||
foreach ($categories as $category) {
|
||||
echo "\n\t<li><a href='" . get_category_link(0, $category->category_id) . "' title='View all posts in $category->cat_name'>$category->cat_name</a></li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
} else {
|
||||
$i = 0;
|
||||
foreach ($categories as $category) {
|
||||
if (0 < $i) echo $seperator . ' ';
|
||||
echo "<a href='" . get_category_link(0, $category->category_id) . "' title='View all posts in $category->cat_name'>$category->cat_name</a>";
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function the_category_rss() {
|
||||
echo convert_chars(strip_tags(get_the_category()), 'xml');
|
||||
}
|
||||
@ -1252,18 +1282,7 @@ function the_category_unicode() {
|
||||
echo convert_chars($category, 'unicode');
|
||||
}
|
||||
|
||||
function get_the_category() {
|
||||
global $post, $tablecategories, $querycount, $cache_categories, $use_cache, $wpdb;
|
||||
$cat_ID = $post->post_category;
|
||||
if ((empty($cache_categories[$cat_ID])) OR (!$use_cache)) {
|
||||
$cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'");
|
||||
++$querycount;
|
||||
$cache_categories[$cat_ID] = $cat_name;
|
||||
} else {
|
||||
$cat_name = $cache_categories[$cat_ID];
|
||||
}
|
||||
return(stripslashes($cat_name));
|
||||
}
|
||||
|
||||
|
||||
function get_the_category_by_ID($cat_ID) {
|
||||
global $tablecategories, $querycount, $cache_categories, $use_cache, $wpdb;
|
||||
|
30
index.php
30
index.php
@ -32,28 +32,28 @@ require_once($abspath.'wp-links/links.php');
|
||||
|
||||
<div id="content">
|
||||
<?php if ($posts) { foreach ($posts as $post) { start_b2(); ?>
|
||||
|
||||
<?php the_date('','<h2>','</h2>'); ?>
|
||||
|
||||
<h3 class="storytitle" id="post-<?php the_ID(); ?>">
|
||||
<a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a>
|
||||
<span class="meta"><a href="<?php get_category_link(1) ?>" title="Category: <?php the_category() ?>">[<?php the_category() ?>]</a> — <?php the_author() ?> @ <?php the_time() ?></span>
|
||||
</h3>
|
||||
<div class="post">
|
||||
<h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h3>
|
||||
<div class="meta">Filed under: <?php the_category() ?> — <?php the_author() ?> @ <?php the_time() ?></div>
|
||||
|
||||
<div class="storycontent">
|
||||
<?php the_content(); ?>
|
||||
</div>
|
||||
<div class="storycontent">
|
||||
<?php the_content(); ?>
|
||||
</div>
|
||||
|
||||
<div class="feedback">
|
||||
<?php link_pages('<br />Pages: ', '<br />', 'number'); ?>
|
||||
<?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?>
|
||||
</div>
|
||||
<div class="feedback">
|
||||
<?php link_pages('<br />Pages: ', '<br />', 'number'); ?>
|
||||
<?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<?php trackback_rdf(); ?>
|
||||
|
||||
-->
|
||||
<!--
|
||||
<?php trackback_rdf(); ?>
|
||||
-->
|
||||
|
||||
<?php include($abspath . 'b2comments.php'); ?>
|
||||
</div>
|
||||
|
||||
<?php } } else { // end foreach, end if any posts ?>
|
||||
<p>Sorry, no posts matched your criteria.</p>
|
||||
|
@ -42,14 +42,14 @@ switch($step) {
|
||||
case 0:
|
||||
?>
|
||||
<p>This file seeks to upgrade you to the latest version of WordPress. If you are upgrading from any version other than .72, you should run the previous upgrade files to get everything up to date before running this.</p>
|
||||
<p>If you’re all ready, <a href="upgrade-072-to-073.php?step=1">let's go</a>! </p>
|
||||
<p>If you’re all ready, <a href="upgrade-072-to-080.php?step=1">let's go</a>! </p>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 1:
|
||||
?>
|
||||
<h1>Step 1</h1>
|
||||
<p>If it isn’t there already, let’s add a field new to this version.</p>
|
||||
<p>If it isn’t there already, let’s add fields new to this version.</p>
|
||||
<?php
|
||||
// Create post_name field
|
||||
$query = "ALTER TABLE `$tableposts` ADD `post_name` VARCHAR(200) NOT NULL";
|
||||
@ -59,9 +59,28 @@ maybe_add_column($tableposts, 'post_name', $query);
|
||||
$wpdb->hide_errors();
|
||||
$wpdb->query("ALTER TABLE `$tableposts` ADD INDEX (`post_name`)");
|
||||
$wpdb->show_errors();
|
||||
|
||||
|
||||
|
||||
// Create category_nicename field
|
||||
$query = "ALTER TABLE `$tablecategories` ADD `category_nicename` VARCHAR(200) NOT NULL";
|
||||
maybe_add_column($tablecategories, 'category_nicename', $query);
|
||||
|
||||
// Create index if it isn't there already, suppress errors if it is
|
||||
$wpdb->hide_errors();
|
||||
$wpdb->query("ALTER TABLE `$tablecategories` ADD INDEX (`category_nicename`)");
|
||||
$wpdb->show_errors();
|
||||
|
||||
// Create category description field
|
||||
$query = "ALTER TABLE `$tablecategories` ADD `category_description` TEXT NOT NULL";
|
||||
maybe_add_column($tablecategories, 'category_description', $query);
|
||||
|
||||
// Create category parent field
|
||||
$query = "ALTER TABLE `$tablecategories` ADD `category_parent` INT(4) NOT NULL";
|
||||
maybe_add_column($tablecategories, 'category_parent', $query);
|
||||
?>
|
||||
<p><strong>Done.</strong></p>
|
||||
<p>Now let's populate the new field.</p>
|
||||
<p><strong>Groovy.</strong></p>
|
||||
<p>Now let’s populate the new fields.</p>
|
||||
<p>Working
|
||||
<?php
|
||||
// Get the title and ID of every post, post_name to check if it already has a value
|
||||
@ -76,6 +95,16 @@ foreach($posts as $post) {
|
||||
flush();
|
||||
}
|
||||
|
||||
$categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $tablecategories");
|
||||
foreach ($categories as $category) {
|
||||
if ('' == $category->category_nicename) {
|
||||
$newtitle = sanitize_title($category->cat_name);
|
||||
$wpdb->query("UPDATE $tablecategories SET category_nicename = '$newtitle' WHERE cat_ID = $category->cat_ID");
|
||||
}
|
||||
echo ' .';
|
||||
flush();
|
||||
}
|
||||
|
||||
if (!$wpdb->get_var("SELECT option_name FROM $tableoptions WHERE option_name = 'permalink_structure'")) { // If it's not already there
|
||||
$wpdb->query("INSERT INTO `$tableoptions`
|
||||
(`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)
|
||||
@ -84,7 +113,7 @@ if (!$wpdb->get_var("SELECT option_name FROM $tableoptions WHERE option_name = '
|
||||
}
|
||||
?>
|
||||
Done with the name game. Now a little option action. </p>
|
||||
<p>Now on to <a href="upgrade-072-to-073.php?step=2">step 2</a>.</p>
|
||||
<p>Now on to <a href="upgrade-072-to-080.php?step=2">step 2</a>.</p>
|
||||
<?php
|
||||
break;
|
||||
case 2:
|
||||
@ -195,7 +224,7 @@ if ($continue) {
|
||||
$wpdb->show_errors();
|
||||
?>
|
||||
<p>Comment spammers should now watch out for you.</p>
|
||||
<p>See, that didn’t hurt a bit (again). Now on to the <a href="upgrade-072-to-073.php?step=3">final step</a>.</p>
|
||||
<p>See, that didn’t hurt a bit (again). Now on to the <a href="upgrade-072-to-080.php?step=3">final step</a>.</p>
|
||||
<?php
|
||||
break;
|
||||
case 3:
|
||||
|
@ -79,9 +79,9 @@ default:
|
||||
<li><code>%monthnum%</code> --- Two digit month, for example 05</li>
|
||||
<li><code>%day% </code>--- Day of the month, for example 28</li>
|
||||
<li><code>%postname%</code> --- A sanitized version of the title of the post. So "This Is A Great Post!" becomes "this-is-a-great-post" </li>
|
||||
<li><code>%category%</code> --- Category name of the post. For example "general". <strong>Not done yet. </strong></li>
|
||||
<li><code>%post_id%</code> --- The unique ID # of the post. <strong></strong></li>
|
||||
</ul>
|
||||
<p>So for example a value like <code>/%year%/%monthnum%/%day%/%postname%/</code> could give you a permalink like <code>/2003/05/23/my-cheese-sandwich</code> . For this to work you'll need mod_rewrite installed on your server for the rule generation rule to work below. In the future there may be other options. </p>
|
||||
<p>So for example a value like <code>/archives/%year%/%monthnum%/%day%/%postname%/</code> could give you a permalink like <code>/archives/2003/05/23/my-cheese-sandwich/</code> . For this to work you'll need mod_rewrite installed on your server for the rule generation rule to work below. In the future there may be other options. </p>
|
||||
<form name="form" action="wp-options-permalink.php" method="post">
|
||||
<p>Use the template tags above to create a virtual site structure:</p>
|
||||
<p>
|
||||
|
@ -55,7 +55,7 @@ cite {
|
||||
h2 {
|
||||
border-bottom: 1px dotted #ccc;
|
||||
font: 80% "Times New Roman", Times, serif;
|
||||
letter-spacing: 0.5em;
|
||||
letter-spacing: 0.2em;
|
||||
margin: 15px 0 2px 0;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
@ -63,7 +63,6 @@ h2 {
|
||||
h3 {
|
||||
border-bottom: dotted 1px #eee;
|
||||
font-family: "Times New Roman", Times, serif;
|
||||
letter-spacing: -0.05em;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
@ -95,12 +94,29 @@ p, li, .feedback {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.meta {
|
||||
font-size: .75em;
|
||||
}
|
||||
|
||||
.meta, .meta a {
|
||||
color: #808080;
|
||||
font-size: small;
|
||||
font-weight: normal;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
.meta ul {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.meta li {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.storytitle {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.storytitle a {
|
||||
text-decoration: none;
|
||||
|
Loading…
Reference in New Issue
Block a user