avoid_blog_page_permalink_collision( array $data, array $postarr )

Avoids a collision between a site slug and a permalink slug.


Description Description

In a subdirectory installation this will make sure that a site and a post do not use the same subdirectory by checking for a site with the same name as a new post.


Parameters Parameters

$data

(array) (Required) An array of post data.

$postarr

(array) (Required) An array of posts. Not currently used.


Top ↑

Return Return

(array) The new array of post data after checking for collisions.


Top ↑

Source Source

File: wp-admin/includes/ms.php

function avoid_blog_page_permalink_collision( $data, $postarr ) {
	if ( is_subdomain_install() ) {
		return $data;
	}
	if ( $data['post_type'] != 'page' ) {
		return $data;
	}
	if ( ! isset( $data['post_name'] ) || $data['post_name'] == '' ) {
		return $data;
	}
	if ( ! is_main_site() ) {
		return $data;
	}

	$post_name = $data['post_name'];
	$c         = 0;
	while ( $c < 10 && get_id_from_blogname( $post_name ) ) {
		$post_name .= mt_rand( 1, 10 );
		$c ++;
	}
	if ( $post_name != $data['post_name'] ) {
		$data['post_name'] = $post_name;
	}
	return $data;
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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