Ticket #3461: move_slug_function.diff
| File move_slug_function.diff, 2.3 KB (added by , 20 years ago) |
|---|
-
wp-includes/post.php
1423 1423 return add_post_meta( $post_id, '_wp_attachment_metadata', $data ); 1424 1424 } 1425 1425 1426 ?> 1426 function wp_check_for_changed_slugs($post_id) { 1427 if ( !strlen($_POST['wp-old-slug']) ) 1428 return $post_id; 1429 1430 $post = &get_post($post_id); 1431 1432 // we're only concerned with published posts 1433 if ( $post->post_status != 'publish' || $post->post_type != 'post' ) 1434 return $post_id; 1435 1436 // only bother if the slug has changed 1437 if ( $post->post_name == $_POST['wp-old-slug'] ) 1438 return $post_id; 1439 1440 $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug'); 1441 1442 // if we haven't added this old slug before, add it now 1443 if ( !count($old_slugs) || !in_array($_POST['wp-old-slug'], $old_slugs) ) 1444 add_post_meta($post_id, '_wp_old_slug', $_POST['wp-old-slug']); 1445 1446 // if the new slug was used previously, delete it from the list 1447 if ( in_array($post->post_name, $old_slugs) ) 1448 delete_post_meta($post_id, '_wp_old_slug', $post->post_name); 1449 1450 return $post_id; 1451 } 1452 1453 ?> 1454 No newline at end of file -
wp-admin/admin-functions.php
1984 1984 } 1985 1985 1986 1986 1987 function wp_check_for_changed_slugs($post_id) {1988 if ( !strlen($_POST['wp-old-slug']) )1989 return $post_id;1990 1991 $post = &get_post($post_id);1992 1993 // we're only concerned with published posts1994 if ( $post->post_status != 'publish' || $post->post_type != 'post' )1995 return $post_id;1996 1997 // only bother if the slug has changed1998 if ( $post->post_name == $_POST['wp-old-slug'] )1999 return $post_id;2000 2001 $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug');2002 2003 // if we haven't added this old slug before, add it now2004 if ( !count($old_slugs) || !in_array($_POST['wp-old-slug'], $old_slugs) )2005 add_post_meta($post_id, '_wp_old_slug', $_POST['wp-old-slug']);2006 2007 // if the new slug was used previously, delete it from the list2008 if ( in_array($post->post_name, $old_slugs) )2009 delete_post_meta($post_id, '_wp_old_slug', $post->post_name);2010 2011 return $post_id;2012 }2013 2014 2015 1987 function wp_remember_old_slug() { 2016 1988 global $post; 2017 1989 $name = wp_specialchars($post->post_name); // just in case
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)