diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 6affb82dce..8efd4d457b 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1984,34 +1984,6 @@ function wp_reset_vars( $vars ) { } -function wp_check_for_changed_slugs($post_id) { - if ( !strlen($_POST['wp-old-slug']) ) - return $post_id; - - $post = &get_post($post_id); - - // we're only concerned with published posts - if ( $post->post_status != 'publish' || $post->post_type != 'post' ) - return $post_id; - - // only bother if the slug has changed - if ( $post->post_name == $_POST['wp-old-slug'] ) - return $post_id; - - $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug'); - - // if we haven't added this old slug before, add it now - if ( !count($old_slugs) || !in_array($_POST['wp-old-slug'], $old_slugs) ) - add_post_meta($post_id, '_wp_old_slug', $_POST['wp-old-slug']); - - // if the new slug was used previously, delete it from the list - if ( in_array($post->post_name, $old_slugs) ) - delete_post_meta($post_id, '_wp_old_slug', $post->post_name); - - return $post_id; -} - - function wp_remember_old_slug() { global $post; $name = wp_specialchars($post->post_name); // just in case diff --git a/wp-includes/post.php b/wp-includes/post.php index 61d1463b38..9d4c35fe6a 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1423,4 +1423,31 @@ function wp_update_attachment_metadata( $post_id, $data ) { return add_post_meta( $post_id, '_wp_attachment_metadata', $data ); } -?> +function wp_check_for_changed_slugs($post_id) { + if ( !strlen($_POST['wp-old-slug']) ) + return $post_id; + + $post = &get_post($post_id); + + // we're only concerned with published posts + if ( $post->post_status != 'publish' || $post->post_type != 'post' ) + return $post_id; + + // only bother if the slug has changed + if ( $post->post_name == $_POST['wp-old-slug'] ) + return $post_id; + + $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug'); + + // if we haven't added this old slug before, add it now + if ( !count($old_slugs) || !in_array($_POST['wp-old-slug'], $old_slugs) ) + add_post_meta($post_id, '_wp_old_slug', $_POST['wp-old-slug']); + + // if the new slug was used previously, delete it from the list + if ( in_array($post->post_name, $old_slugs) ) + delete_post_meta($post_id, '_wp_old_slug', $post->post_name); + + return $post_id; +} + +?> \ No newline at end of file