2004-01-27 10:58:01 +01:00
|
|
|
<?php
|
|
|
|
|
2004-04-21 06:12:55 +02:00
|
|
|
function the_permalink() {
|
|
|
|
echo get_permalink();
|
|
|
|
}
|
|
|
|
|
2004-01-27 10:58:01 +01:00
|
|
|
function permalink_anchor($mode = 'id') {
|
|
|
|
global $id, $post;
|
|
|
|
switch(strtolower($mode)) {
|
|
|
|
case 'title':
|
|
|
|
$title = sanitize_title($post->post_title) . '-' . $id;
|
|
|
|
echo '<a id="'.$title.'"></a>';
|
|
|
|
break;
|
|
|
|
case 'id':
|
|
|
|
default:
|
|
|
|
echo '<a id="post-'.$id.'"></a>';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function permalink_link($file='', $mode = 'id') {
|
|
|
|
global $post, $pagenow, $cacheweekly, $wpdb;
|
|
|
|
$file = ($file=='') ? $pagenow : $file;
|
|
|
|
switch(strtolower($mode)) {
|
|
|
|
case 'title':
|
|
|
|
$title = sanitize_title($post->post_title) . '-' . $post->ID;
|
|
|
|
$anchor = $title;
|
|
|
|
break;
|
|
|
|
case 'id':
|
|
|
|
default:
|
|
|
|
$anchor = $id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
echo get_permalink();
|
|
|
|
}
|
|
|
|
|
|
|
|
function permalink_single($file = '') {
|
|
|
|
echo get_permalink();
|
|
|
|
}
|
|
|
|
|
|
|
|
function permalink_single_rss($file = '') {
|
|
|
|
echo get_permalink();
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_permalink($id=false) {
|
|
|
|
global $post, $wpdb, $tableposts;
|
2004-02-26 17:15:48 +01:00
|
|
|
global $querystring_start, $querystring_equal;
|
2004-01-27 10:58:01 +01:00
|
|
|
|
|
|
|
$rewritecode = array(
|
|
|
|
'%year%',
|
|
|
|
'%monthnum%',
|
|
|
|
'%day%',
|
2004-05-05 09:34:41 +02:00
|
|
|
'%hour%',
|
|
|
|
'%minute%',
|
|
|
|
'%second%',
|
2004-01-27 10:58:01 +01:00
|
|
|
'%postname%',
|
|
|
|
'%post_id%'
|
|
|
|
);
|
|
|
|
if (!$id) {
|
|
|
|
if ('' != get_settings('permalink_structure')) {
|
2004-03-25 03:04:15 +01:00
|
|
|
$unixtime = strtotime($post->post_date);
|
2004-01-27 10:58:01 +01:00
|
|
|
$rewritereplace = array(
|
|
|
|
date('Y', $unixtime),
|
|
|
|
date('m', $unixtime),
|
|
|
|
date('d', $unixtime),
|
2004-05-05 09:34:41 +02:00
|
|
|
date('H', $unixtime),
|
|
|
|
date('i', $unixtime),
|
|
|
|
date('s', $unixtime),
|
2004-01-27 10:58:01 +01:00
|
|
|
$post->post_name,
|
|
|
|
$post->ID
|
|
|
|
);
|
2004-04-28 09:27:03 +02:00
|
|
|
return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
|
2004-01-27 10:58:01 +01:00
|
|
|
} else { // if they're not using the fancy permalink option
|
2004-04-28 09:27:03 +02:00
|
|
|
return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$post->ID;
|
2004-01-27 10:58:01 +01:00
|
|
|
}
|
|
|
|
} else { // if an ID is given
|
|
|
|
$idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id");
|
|
|
|
if ('' != get_settings('permalink_structure')) {
|
2004-03-25 03:04:15 +01:00
|
|
|
$unixtime = strtotime($idpost->post_date);
|
2004-01-27 10:58:01 +01:00
|
|
|
$rewritereplace = array(
|
|
|
|
date('Y', $unixtime),
|
|
|
|
date('m', $unixtime),
|
|
|
|
date('d', $unixtime),
|
2004-05-05 09:34:41 +02:00
|
|
|
date('H', $unixtime),
|
|
|
|
date('i', $unixtime),
|
|
|
|
date('s', $unixtime),
|
2004-01-27 10:58:01 +01:00
|
|
|
$idpost->post_name,
|
|
|
|
$id
|
|
|
|
);
|
2004-04-28 09:27:03 +02:00
|
|
|
return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
|
2004-01-27 10:58:01 +01:00
|
|
|
} else {
|
2004-04-28 09:27:03 +02:00
|
|
|
return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$id;
|
2004-01-27 10:58:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_month_link($year, $month) {
|
2004-02-26 17:15:48 +01:00
|
|
|
global $querystring_start, $querystring_equal;
|
2004-04-24 23:52:24 +02:00
|
|
|
if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
|
|
|
|
if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
|
2004-01-27 10:58:01 +01:00
|
|
|
if ('' != get_settings('permalink_structure')) {
|
|
|
|
$off = strpos(get_settings('permalink_structure'), '%monthnum%');
|
|
|
|
$offset = $off + 11;
|
|
|
|
$monthlink = substr(get_settings('permalink_structure'), 0, $offset);
|
|
|
|
if ('/' != substr($monthlink, -1)) $monthlink = substr($monthlink, 0, -1);
|
|
|
|
$monthlink = str_replace('%year%', $year, $monthlink);
|
|
|
|
$monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
|
|
|
|
$monthlink = str_replace('%post_id%', '', $monthlink);
|
2004-04-28 09:27:03 +02:00
|
|
|
return get_settings('home') . $monthlink;
|
2004-01-27 10:58:01 +01:00
|
|
|
} else {
|
2004-04-28 09:27:03 +02:00
|
|
|
return get_settings('home') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2);
|
2004-01-27 10:58:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_day_link($year, $month, $day) {
|
2004-02-26 17:15:48 +01:00
|
|
|
global $querystring_start, $querystring_equal;
|
2004-04-24 23:52:24 +02:00
|
|
|
if (!$year) $year = gmdate('Y', time()+(get_settings('gmt_offset') * 3600));
|
|
|
|
if (!$month) $month = gmdate('m', time()+(get_settings('gmt_offset') * 3600));
|
|
|
|
if (!$day) $day = gmdate('j', time()+(get_settings('gmt_offset') * 3600));
|
2004-01-27 10:58:01 +01:00
|
|
|
if ('' != get_settings('permalink_structure')) {
|
|
|
|
$off = strpos(get_settings('permalink_structure'), '%day%');
|
|
|
|
$offset = $off + 6;
|
|
|
|
$daylink = substr(get_settings('permalink_structure'), 0, $offset);
|
|
|
|
if ('/' != substr($daylink, -1)) $daylink = substr($daylink, 0, -1);
|
|
|
|
$daylink = str_replace('%year%', $year, $daylink);
|
|
|
|
$daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
|
|
|
|
$daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
|
|
|
|
$daylink = str_replace('%post_id%', '', $daylink);
|
2004-04-28 09:27:03 +02:00
|
|
|
return get_settings('home') . $daylink;
|
2004-01-27 10:58:01 +01:00
|
|
|
} else {
|
2004-04-28 09:27:03 +02:00
|
|
|
return get_settings('home') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2);
|
2004-01-27 10:58:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function edit_post_link($link = 'Edit This', $before = '', $after = '') {
|
2004-02-26 17:15:48 +01:00
|
|
|
global $user_level, $post;
|
2004-01-27 10:58:01 +01:00
|
|
|
|
|
|
|
get_currentuserinfo();
|
|
|
|
|
|
|
|
if ($user_level > 0) {
|
|
|
|
$authordata = get_userdata($post->post_author);
|
|
|
|
if ($user_level < $authordata->user_level) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-26 17:15:48 +01:00
|
|
|
$location = get_settings('siteurl') . "/wp-admin/post.php?action=edit&post=$post->ID";
|
2004-02-20 02:53:41 +01:00
|
|
|
echo "$before <a href=\"$location\">$link</a> $after";
|
2004-01-27 10:58:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
|
2004-02-26 17:15:48 +01:00
|
|
|
global $user_level, $post, $comment;
|
2004-01-27 10:58:01 +01:00
|
|
|
|
|
|
|
get_currentuserinfo();
|
|
|
|
|
|
|
|
if ($user_level > 0) {
|
|
|
|
$authordata = get_userdata($post->post_author);
|
|
|
|
if ($user_level < $authordata->user_level) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-02-26 17:15:48 +01:00
|
|
|
$location = get_settings('siteurl') . "/wp-admin/post.php?action=editcomment&comment=$comment->comment_ID";
|
2004-02-20 02:53:41 +01:00
|
|
|
echo "$before <a href=\"$location\">$link</a> $after";
|
2004-01-27 10:58:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|