From d0e0ceb7487148b7c56ed1afba6a90764db08027 Mon Sep 17 00:00:00 2001 From: markjaquith Date: Sun, 10 Dec 2006 17:17:39 +0000 Subject: [PATCH] Move wp_check_for_changed_slugs() to post.php so it can be called in non-admin contexts. fixes #3461 git-svn-id: http://svn.automattic.com/wordpress/trunk@4637 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-functions.php | 28 ---------------------------- wp-includes/post.php | 29 ++++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 29 deletions(-) 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