summaryrefslogtreecommitdiffstats
path: root/wp-includes/link-template.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-08-31 14:55:29 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-08-31 14:55:29 +0000
commitb764f60728be1d4e026f9d7ae618ab47e23322f8 (patch)
tree1f1b45c4f1c1cf027b3240f605346e56209be8ff /wp-includes/link-template.php
parentdad010666b767a1d06588d1d09c771c62f67c387 (diff)
downloadwordpress-mu-b764f60728be1d4e026f9d7ae618ab47e23322f8.tar.gz
wordpress-mu-b764f60728be1d4e026f9d7ae618ab47e23322f8.tar.xz
wordpress-mu-b764f60728be1d4e026f9d7ae618ab47e23322f8.zip
WP Merge to rev #4147
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@729 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/link-template.php')
-rw-r--r--wp-includes/link-template.php64
1 files changed, 33 insertions, 31 deletions
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index 81f4d7c..965c4e4 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -47,7 +47,7 @@ function get_permalink($id = 0) {
elseif ($post->post_type == 'attachment')
return get_attachment_link($post->ID);
- $permalink = get_settings('permalink_structure');
+ $permalink = get_option('permalink_structure');
if ( '' != $permalink && 'draft' != $post->post_status ) {
$unixtime = strtotime($post->post_date);
@@ -77,9 +77,9 @@ function get_permalink($id = 0) {
$author,
$post->post_name,
);
- return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post);
+ return apply_filters('post_link', get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post);
} else { // if they're not using the fancy permalink option
- $permalink = get_settings('home') . '/?p=' . $post->ID;
+ $permalink = get_option('home') . '/?p=' . $post->ID;
return apply_filters('post_link', $permalink, $post);
}
}
@@ -100,13 +100,13 @@ function get_page_link($id = false) {
if ( '' != $pagestruct && 'draft' != $post->post_status ) {
$link = get_page_uri($id);
$link = str_replace('%pagename%', $link, $pagestruct);
- $link = get_settings('home') . "/$link/";
+ $link = get_option('home') . "/$link/";
} else {
- $link = get_settings('home') . "/?page_id=$id";
+ $link = get_option('home') . "/?page_id=$id";
}
if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
- $link = get_settings('home');
+ $link = get_option('home');
return apply_filters('page_link', $link, $id);
}
@@ -138,56 +138,56 @@ function get_attachment_link($id = false) {
function get_year_link($year) {
global $wp_rewrite;
if ( !$year )
- $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
+ $year = gmdate('Y', time()+(get_option('gmt_offset') * 3600));
$yearlink = $wp_rewrite->get_year_permastruct();
if ( !empty($yearlink) ) {
$yearlink = str_replace('%year%', $year, $yearlink);
- return apply_filters('year_link', get_settings('home') . trailingslashit($yearlink), $year);
+ return apply_filters('year_link', get_option('home') . trailingslashit($yearlink), $year);
} else {
- return apply_filters('year_link', get_settings('home') . '/?m=' . $year, $year);
+ return apply_filters('year_link', get_option('home') . '/?m=' . $year, $year);
}
}
function get_month_link($year, $month) {
global $wp_rewrite;
if ( !$year )
- $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
+ $year = gmdate('Y', time()+(get_option('gmt_offset') * 3600));
if ( !$month )
- $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
+ $month = gmdate('m', time()+(get_option('gmt_offset') * 3600));
$monthlink = $wp_rewrite->get_month_permastruct();
if ( !empty($monthlink) ) {
$monthlink = str_replace('%year%', $year, $monthlink);
$monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
- return apply_filters('month_link', get_settings('home') . trailingslashit($monthlink), $year, $month);
+ return apply_filters('month_link', get_option('home') . trailingslashit($monthlink), $year, $month);
} else {
- return apply_filters('month_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2), $year, $month);
+ return apply_filters('month_link', get_option('home') . '/?m=' . $year . zeroise($month, 2), $year, $month);
}
}
function get_day_link($year, $month, $day) {
global $wp_rewrite;
if ( !$year )
- $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
+ $year = gmdate('Y', time()+(get_option('gmt_offset') * 3600));
if ( !$month )
- $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
+ $month = gmdate('m', time()+(get_option('gmt_offset') * 3600));
if ( !$day )
- $day = gmdate('j', time()+(get_settings('gmt_offset') * 3600));
+ $day = gmdate('j', time()+(get_option('gmt_offset') * 3600));
$daylink = $wp_rewrite->get_day_permastruct();
if ( !empty($daylink) ) {
$daylink = str_replace('%year%', $year, $daylink);
$daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
$daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
- return apply_filters('day_link', get_settings('home') . trailingslashit($daylink), $year, $month, $day);
+ return apply_filters('day_link', get_option('home') . trailingslashit($daylink), $year, $month, $day);
} else {
- return apply_filters('day_link', get_settings('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);
+ return apply_filters('day_link', get_option('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);
}
}
function get_feed_link($feed='rss2') {
global $wp_rewrite;
$do_perma = 0;
- $feed_url = get_settings('siteurl');
+ $feed_url = get_option('siteurl');
$comment_feed_url = $feed_url;
$permalink = $wp_rewrite->get_feed_permastruct();
@@ -202,12 +202,12 @@ function get_feed_link($feed='rss2') {
$permalink = str_replace('%feed%', $feed, $permalink);
$permalink = preg_replace('#/+#', '/', "/$permalink/");
- $output = get_settings('home') . $permalink;
+ $output = get_option('home') . $permalink;
} else {
if ( false !== strpos($feed, 'comments_') )
$feed = str_replace('comments_', 'comments-', $feed);
- $output = get_settings('home') . "/?feed={$feed}";
+ $output = get_option('home') . "/?feed={$feed}";
}
return apply_filters('feed_link', $output, $feed);
@@ -229,7 +229,7 @@ function edit_post_link($link = 'Edit This', $before = '', $after = '') {
$file = 'post';
}
- $location = get_settings('siteurl') . "/wp-admin/{$file}.php?action=edit&amp;post=$post->ID";
+ $location = get_option('siteurl') . "/wp-admin/{$file}.php?action=edit&amp;post=$post->ID";
echo $before . "<a href=\"$location\">$link</a>" . $after;
}
@@ -244,7 +244,7 @@ function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
return;
}
- $location = get_settings('siteurl') . "/wp-admin/comment.php?action=editcomment&amp;comment=$comment->comment_ID";
+ $location = get_option('siteurl') . "/wp-admin/comment.php?action=editcomment&amp;comment=$comment->comment_ID";
echo $before . "<a href='$location'>$link</a>" . $after;
}
@@ -362,7 +362,7 @@ function get_pagenum_link($pagenum = 1) {
$page_modregex = "page/?";
$permalink = 0;
- $home_root = parse_url(get_settings('home'));
+ $home_root = parse_url(get_option('home'));
$home_root = $home_root['path'];
$home_root = trailingslashit($home_root);
$qstr = preg_replace('|^'. $home_root . '|', '', $qstr);
@@ -390,7 +390,7 @@ function get_pagenum_link($pagenum = 1) {
// so append the query string (using &, since we already have ?)
$qstr .= '&amp;' . $page_querystring . '=' . $pagenum;
// otherwise, it could be rewritten, OR just the default index ...
- } elseif( '' != get_settings('permalink_structure') && ! is_admin() ) {
+ } elseif( '' != get_option('permalink_structure') && ! is_admin() ) {
$permalink = 1;
$index = $wp_rewrite->index;
// If it's not a path info permalink structure, trim the index.
@@ -398,7 +398,7 @@ function get_pagenum_link($pagenum = 1) {
$qstr = preg_replace("#/*" . $index . "/*#", '/', $qstr);
} else {
// If using path info style permalinks, make sure the index is in
- // the URI.
+ // the URL.
if ( strpos($qstr, $index) === false )
$qstr = '/' . $index . $qstr;
}
@@ -412,14 +412,14 @@ function get_pagenum_link($pagenum = 1) {
$qstr = preg_replace('|^/+|', '', $qstr);
if ( $permalink )
$qstr = trailingslashit($qstr);
- $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', trailingslashit( get_settings('home') ) . $qstr );
+ $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', trailingslashit( get_option('home') ) . $qstr );
// showing /page/1/ or ?paged=1 is redundant
if ( 1 === $pagenum ) {
$qstr = str_replace('page/1/', '', $qstr); // for mod_rewrite style
$qstr = remove_query_arg('paged', $qstr); // for query style
}
- return str_replace( "wp-inst/", "", $qstr );
+ return $qstr;
}
function next_posts($max_page = 0) { // original by cfactor at cooltux.org
@@ -476,17 +476,19 @@ function _max_num_pages() {
global $wpdb, $wp_query;
if (isset($max_num_pages)) return $max_num_pages;
-
+ $posts_per = (int) get_option('posts_per_page');
+ if ( empty($posts_per) ) $posts_per = 1;
+
if ( 'posts' == get_query_var('what_to_show') ) {
preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
$fromwhere = $matches[1];
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
- $max_num_pages = ceil($numposts / get_option('posts_per_page'));
+ $max_num_pages = ceil($numposts / $posts_per);
} else {
preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
$fromwhere = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
$num_days = $wpdb->query("SELECT DISTINCT post_date FROM $fromwhere GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
- $max_num_pages = ceil($num_days / get_option('posts_per_page'));
+ $max_num_pages = ceil($num_days / $posts_per);
}
return $max_num_pages;