Changeset 14814
- Timestamp:
- 05/23/2010 07:49:21 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r14768 r14814 2763 2763 2764 2764 /** 2765 * {@internal Missing Short Description}}2766 *2767 * @since unknown2768 */2769 function wp_remember_old_slug() {2770 global $post;2771 $name = esc_attr($post->post_name); // just in case2772 if ( strlen($name) )2773 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';2774 }2775 2776 /**2777 2765 * Add a meta box to an edit form. 2778 2766 * -
trunk/wp-includes/default-filters.php
r14295 r14814 236 236 237 237 // Redirect Old Slugs 238 add_action( 'template_redirect', 'wp_old_slug_redirect' ); 239 add_action( 'edit_post', 'wp_check_for_changed_slugs' ); 240 add_action( 'edit_form_advanced', 'wp_remember_old_slug' ); 241 add_action( 'init', '_show_post_preview' ); 238 add_action( 'template_redirect', 'wp_old_slug_redirect' ); 239 add_action( 'post_updated', 'wp_check_for_changed_slugs', 12, 3 ); 240 241 // Nonce check for Post Previews 242 add_action( 'init', '_show_post_preview' ); 242 243 243 244 // Timezone -
trunk/wp-includes/post.php
r14713 r14814 1656 1656 * 1657 1657 * @param string|array $mime_types List of mime types or comma separated string of mime types. 1658 * @param string $table_alias Optional. Specify a table alias, if needed. 1658 * @param string $table_alias Optional. Specify a table alias, if needed. 1659 1659 * @return string The SQL AND clause for mime searching. 1660 1660 */ … … 2200 2200 $post_ID = (int) $ID; 2201 2201 $guid = get_post_field( 'guid', $post_ID ); 2202 $post_before = get_post($post_ID); 2202 2203 } 2203 2204 … … 2375 2376 wp_transition_post_status($data['post_status'], $previous_status, $post); 2376 2377 2377 if ( $update ) 2378 if ( $update ) { 2378 2379 do_action('edit_post', $post_ID, $post); 2380 $post_after = get_post($post_ID); 2381 do_action( 'post_updated', $post_ID, $post_after, $post_before); 2382 } 2379 2383 2380 2384 do_action('save_post', $post_ID, $post); … … 3779 3783 * @return int Same as $post_id 3780 3784 */ 3781 function wp_check_for_changed_slugs($post_id) { 3782 if ( empty($_POST['wp-old-slug']) ) 3783 return $post_id; 3784 3785 $post = &get_post($post_id); 3785 function wp_check_for_changed_slugs($post_id, $post, $post_before) { 3786 // dont bother if it hasnt changed 3787 if ( $post->post_name == $post_before->post_name ) 3788 return; 3786 3789 3787 3790 // we're only concerned with published posts 3788 3791 if ( $post->post_status != 'publish' || $post->post_type != 'post' ) 3789 return $post_id; 3790 3791 // only bother if the slug has changed 3792 if ( $post->post_name == $_POST['wp-old-slug'] ) 3793 return $post_id; 3792 return; 3794 3793 3795 3794 $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug'); 3796 3795 3797 3796 // if we haven't added this old slug before, add it now 3798 if ( ! count($old_slugs) || !in_array($_POST['wp-old-slug'], $old_slugs) )3799 add_post_meta($post_id, '_wp_old_slug', $ _POST['wp-old-slug']);3797 if ( !in_array($post_before->post_name, $old_slugs) ) 3798 add_post_meta($post_id, '_wp_old_slug', $post_before->post_name); 3800 3799 3801 3800 // if the new slug was used previously, delete it from the list 3802 3801 if ( in_array($post->post_name, $old_slugs) ) 3803 3802 delete_post_meta($post_id, '_wp_old_slug', $post->post_name); 3804 3805 return $post_id;3806 3803 } 3807 3804
Note: See TracChangeset
for help on using the changeset viewer.