wp_check_for_changed_slugs( int $post_id, WP_Post $post, WP_Post $post_before )

Checks for changed slugs for published post objects and save the old slug.

Description

The function is used when a post object of any type is updated, by comparing the current and previous post objects.

If the slug was changed and not already part of the old slugs then it will be added to the post meta field (‘_wp_old_slug’) for storing old slugs for that post.

The most logically usage of this function is redirecting changed post objects, so that those that linked to an changed post will be redirected to the new post.

Parameters

$post_idintrequired
Post ID.
$postWP_Postrequired
The post object.
$post_beforeWP_Postrequired
The previous post object.

Source

		$post_mimes[] = str_replace( '/', '_', $mime );
	}

	$matches            = wp_match_mime_types( array_keys( $types ), $post_mimes );
	$matches['default'] = array( 'default' );

	foreach ( $matches as $match => $wilds ) {
		foreach ( $wilds as $wild ) {
			if ( ! isset( $types[ $wild ] ) ) {
				continue;
			}

			$icon = $types[ $wild ];
			if ( ! is_numeric( $mime ) ) {
				wp_cache_add( "mime_type_icon_$mime", $icon );
			}
			break 2;
		}
	}
}

/**
 * Filters the mime type icon.

Changelog

VersionDescription
2.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.