Static pages. Take 1.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -454,11 +454,16 @@ class WP_Query {
|
||||
|
||||
$distinct = 'DISTINCT';
|
||||
}
|
||||
$where .= ' AND (post_status = "publish"';
|
||||
|
||||
if ('' != $q['static']) {
|
||||
$where .= ' AND (post_status = "static"';
|
||||
} else {
|
||||
$where .= ' AND (post_status = "publish"';
|
||||
}
|
||||
|
||||
// Get private posts
|
||||
if (isset($user_ID) && ('' != intval($user_ID)))
|
||||
$where .= " OR post_author = $user_ID AND post_status != 'draft')";
|
||||
$where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
|
||||
else
|
||||
$where .= ')';
|
||||
|
||||
|
||||
@@ -1175,6 +1175,24 @@ function preg_index($number, $matches = '') {
|
||||
return "$match_prefix$number$match_suffix";
|
||||
}
|
||||
|
||||
|
||||
function page_permastruct() {
|
||||
$permalink_structure = get_settings('permalink_structure');
|
||||
|
||||
if (empty($permalink_structure)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
|
||||
$index = get_settings('blogfilename');
|
||||
$prefix = '';
|
||||
if (preg_match('#^/*' . $index . '#', $front)) {
|
||||
$prefix = $index . '/';
|
||||
}
|
||||
|
||||
return '/' . $prefix . 'site/%pagename%';
|
||||
}
|
||||
|
||||
function generate_rewrite_rules($permalink_structure = '', $matches = '') {
|
||||
$rewritecode =
|
||||
array(
|
||||
@@ -1187,7 +1205,8 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') {
|
||||
'%postname%',
|
||||
'%post_id%',
|
||||
'%category%',
|
||||
'%author%'
|
||||
'%author%',
|
||||
'%pagename%'
|
||||
);
|
||||
|
||||
$rewritereplace =
|
||||
@@ -1201,7 +1220,8 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') {
|
||||
'([_0-9a-z-]+)',
|
||||
'([0-9]+)',
|
||||
'([/_0-9a-z-]+)',
|
||||
'([_0-9a-z-]+)'
|
||||
'([_0-9a-z-]+)',
|
||||
'([_0-9a-z-]+)',
|
||||
);
|
||||
|
||||
$queryreplace =
|
||||
@@ -1215,7 +1235,8 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') {
|
||||
'name=',
|
||||
'p=',
|
||||
'category_name=',
|
||||
'author_name='
|
||||
'author_name=',
|
||||
'static=1&name=',
|
||||
);
|
||||
|
||||
$feedregex = '(feed|rdf|rss|rss2|atom)/?$';
|
||||
@@ -1355,8 +1376,12 @@ function rewrite_rules($matches = '', $permalink_structure = '') {
|
||||
$author_structure = $front . 'author/%author%';
|
||||
$author_rewrite = generate_rewrite_rules($author_structure, $matches);
|
||||
|
||||
// Site static pages
|
||||
$page_structure = $prefix . 'site/%pagename%';
|
||||
$page_rewrite = generate_rewrite_rules($page_structure, $matches);
|
||||
|
||||
// Put them together.
|
||||
$rewrite = $site_rewrite + $category_rewrite + $author_rewrite;
|
||||
$rewrite = $site_rewrite + $page_rewrite + $category_rewrite + $author_rewrite;
|
||||
|
||||
// Add on archive rewrite rules if needed.
|
||||
if ($doarchive) {
|
||||
@@ -1464,8 +1489,10 @@ function update_post_caches($posts) {
|
||||
FROM $wpdb->categories, $wpdb->post2cat, $wpdb->posts
|
||||
WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
|
||||
|
||||
foreach ($dogs as $catt) {
|
||||
$category_cache[$catt->ID][] = $catt;
|
||||
if (!empty($dogs)) {
|
||||
foreach ($dogs as $catt) {
|
||||
$category_cache[$catt->ID][] = $catt;
|
||||
}
|
||||
}
|
||||
|
||||
// Do the same for comment numbers
|
||||
|
||||
@@ -64,6 +64,11 @@ function get_category_rss_link($echo = false, $category_id, $category_nicename)
|
||||
|
||||
function the_category($seperator = '', $parents='') {
|
||||
$categories = get_the_category();
|
||||
if (empty($categories)) {
|
||||
_e('Uncategorized');
|
||||
return;
|
||||
}
|
||||
|
||||
$thelist = '';
|
||||
if ('' == $seperator) {
|
||||
$thelist .= '<ul class="post-categories">';
|
||||
|
||||
@@ -39,16 +39,23 @@ function get_permalink($id=false) {
|
||||
'%second%',
|
||||
'%postname%',
|
||||
'%post_id%',
|
||||
'%category%'
|
||||
'%category%',
|
||||
'%pagename%'
|
||||
);
|
||||
|
||||
if ($id) {
|
||||
$idpost = $wpdb->get_row("SELECT ID, post_date, post_name FROM $wpdb->posts WHERE ID = $id");
|
||||
$idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status FROM $wpdb->posts WHERE ID = $id");
|
||||
} else {
|
||||
$idpost = $post;
|
||||
}
|
||||
|
||||
if ('' != get_settings('permalink_structure')) {
|
||||
|
||||
$permalink = get_settings('permalink_structure');
|
||||
|
||||
if ('' != $permalink) {
|
||||
if ($idpost->post_status == 'static') {
|
||||
$permalink = page_permastruct();
|
||||
}
|
||||
|
||||
$unixtime = strtotime($idpost->post_date);
|
||||
|
||||
$cats = get_the_category($idpost->ID);
|
||||
@@ -63,11 +70,15 @@ function get_permalink($id=false) {
|
||||
date('s', $unixtime),
|
||||
$idpost->post_name,
|
||||
$idpost->ID,
|
||||
$category
|
||||
$category,
|
||||
$idpost->post_name,
|
||||
);
|
||||
return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
|
||||
return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink);
|
||||
} else { // if they're not using the fancy permalink option
|
||||
return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID;
|
||||
$permalink = get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID;
|
||||
if ($idpost->post_status == 'static') {
|
||||
$permalink .= $querystring_separator . "static=1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user