Taxonomy: Disallow overriding the `name` property when registering a taxonomy.
Props wpfo for initial patch, swissspidy. Merges [40049] to the 4.7 branch. Fixes #39308. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40083 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
72294c9caa
commit
8531c4e5a6
|
@ -333,6 +333,8 @@ final class WP_Taxonomy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$args['name'] = $this->name;
|
||||||
|
|
||||||
foreach ( $args as $property_name => $property_value ) {
|
foreach ( $args as $property_name => $property_value ) {
|
||||||
$this->$property_name = $property_value;
|
$this->$property_name = $property_value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -710,4 +710,15 @@ class Tests_Taxonomy extends WP_UnitTestCase {
|
||||||
$this->assertFalse( taxonomy_exists( 'foo' ) );
|
$this->assertFalse( taxonomy_exists( 'foo' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 39308
|
||||||
|
*/
|
||||||
|
public function test_taxonomy_name_property_should_not_get_overridden_by_passed_args() {
|
||||||
|
register_taxonomy( 'foo', 'post', array( 'name' => 'bar' ) );
|
||||||
|
|
||||||
|
$taxonomy = get_taxonomy( 'foo' );
|
||||||
|
unregister_taxonomy( 'foo' );
|
||||||
|
|
||||||
|
$this->assertSame( 'foo', $taxonomy->name );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue