Meta: Make registration error conditions return consistently.

In doing this, non-core object types are no longer forcibly blocked and are instead checked against `wp_object_type_exists()` which has a filterable return value. Still, filter that at your own risk.

props Faison for the initial patch.
see 35658.

Built from https://develop.svn.wordpress.org/trunk@37991


git-svn-id: http://core.svn.wordpress.org/trunk@37932 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí
2016-07-06 18:09:32 +00:00
parent dc57f35048
commit 5a2ffe61f6
3 changed files with 36 additions and 13 deletions

View File

@@ -5356,3 +5356,26 @@ function mysql_to_rfc3339( $date_string ) {
// Strip timezone information
return preg_replace( '/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted );
}
/**
* Check if an object type exists. By default, these are `post`, `comment`, `user`, and `term`.
*
* @param string $object_type Object type to check.
* @return bool True if the object type exists, false if not.
*/
function wp_object_type_exists( $object_type ) {
/**
* Filters WordPress object types.
*
* @since 4.6.0
*
* @param array $types Array of object types.
*/
$types = apply_filters( 'wp_object_types', array( 'post', 'comment', 'user', 'term' ) );
if ( in_array( $object_type, $types ) ) {
return true;
}
return false;
}