Set GUID on upgrade. CURRENTLY NOT WORKING. For some reason the get_settings calls aren't working.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ed34ca04d8
commit
c54f9a539f
|
@ -147,13 +147,18 @@ function upgrade_130() {
|
||||||
global $wpdb, $table_prefix;
|
global $wpdb, $table_prefix;
|
||||||
|
|
||||||
// Remove extraneous backslashes.
|
// Remove extraneous backslashes.
|
||||||
$posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt FROM $wpdb->posts");
|
$posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
|
||||||
if ($posts) {
|
if ($posts) {
|
||||||
foreach($posts as $post) {
|
foreach($posts as $post) {
|
||||||
$post_content = addslashes(deslash($post->post_content));
|
$post_content = addslashes(deslash($post->post_content));
|
||||||
$post_title = addslashes(deslash($post->post_title));
|
$post_title = addslashes(deslash($post->post_title));
|
||||||
$post_excerpt = addslashes(deslash($post->post_excerpt));
|
$post_excerpt = addslashes(deslash($post->post_excerpt));
|
||||||
$wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt' WHERE ID = '$post->ID'");
|
if ( empty($post->guid) )
|
||||||
|
$guid = get_option('home') . '/' . get_permalink();
|
||||||
|
else
|
||||||
|
$guid = $post->guid;
|
||||||
|
|
||||||
|
$wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,65 +26,62 @@ function permalink_single_rss($file = '') {
|
||||||
echo get_permalink();
|
echo get_permalink();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_permalink($id=false) {
|
function get_permalink($id = false) {
|
||||||
global $post, $wpdb;
|
global $post, $wpdb;
|
||||||
global $querystring_start, $querystring_equal;
|
|
||||||
|
|
||||||
$rewritecode = array(
|
$rewritecode = array(
|
||||||
'%year%',
|
'%year%',
|
||||||
'%monthnum%',
|
'%monthnum%',
|
||||||
'%day%',
|
'%day%',
|
||||||
'%hour%',
|
'%hour%',
|
||||||
'%minute%',
|
'%minute%',
|
||||||
'%second%',
|
'%second%',
|
||||||
'%postname%',
|
'%postname%',
|
||||||
'%post_id%',
|
'%post_id%',
|
||||||
'%category%',
|
'%category%',
|
||||||
'%author%',
|
'%author%',
|
||||||
'%pagename%'
|
'%pagename%'
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id");
|
$idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id");
|
||||||
} else {
|
} else {
|
||||||
$idpost = $post;
|
$idpost = $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
$permalink = get_settings('permalink_structure');
|
$permalink = get_settings('permalink_structure');
|
||||||
|
|
||||||
if ('' != $permalink) {
|
if ('' != $permalink) {
|
||||||
if ($idpost->post_status == 'static') {
|
if ($idpost->post_status == 'static')
|
||||||
$permalink = page_permastruct();
|
$permalink = page_permastruct();
|
||||||
}
|
|
||||||
|
|
||||||
$unixtime = strtotime($idpost->post_date);
|
$unixtime = strtotime($idpost->post_date);
|
||||||
|
|
||||||
$cats = get_the_category($idpost->ID);
|
$cats = get_the_category($idpost->ID);
|
||||||
$category = $cats[0]->category_nicename;
|
$category = $cats[0]->category_nicename;
|
||||||
$authordata = get_userdata($idpost->post_author);
|
$authordata = get_userdata($idpost->post_author);
|
||||||
$author = $authordata->user_nicename;
|
$author = $authordata->user_nicename;
|
||||||
|
$rewritereplace =
|
||||||
$rewritereplace = array(
|
array(
|
||||||
date('Y', $unixtime),
|
date('Y', $unixtime),
|
||||||
date('m', $unixtime),
|
date('m', $unixtime),
|
||||||
date('d', $unixtime),
|
date('d', $unixtime),
|
||||||
date('H', $unixtime),
|
date('H', $unixtime),
|
||||||
date('i', $unixtime),
|
date('i', $unixtime),
|
||||||
date('s', $unixtime),
|
date('s', $unixtime),
|
||||||
$idpost->post_name,
|
$idpost->post_name,
|
||||||
$idpost->ID,
|
$idpost->ID,
|
||||||
$category,
|
$category,
|
||||||
$author,
|
$author,
|
||||||
$idpost->post_name,
|
$idpost->post_name,
|
||||||
);
|
);
|
||||||
return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink);
|
return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink);
|
||||||
} else { // if they're not using the fancy permalink option
|
} else { // if they're not using the fancy permalink option
|
||||||
$permalink = get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID;
|
$permalink = get_settings('home') . '/' . get_settings('blogfilename') . '?p=' . $idpost->ID;
|
||||||
if ($idpost->post_status == 'static') {
|
if ($idpost->post_status == 'static')
|
||||||
$permalink .= $querystring_separator . "static=1";
|
$permalink .= '&static=1';
|
||||||
}
|
return $permalink;
|
||||||
return $permalink;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_month_link($year, $month) {
|
function get_month_link($year, $month) {
|
||||||
|
|
Loading…
Reference in New Issue