Changeset 36646
- Timestamp:
- 02/23/2016 08:06:25 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/link-template.php
r36494 r36646 908 908 * 909 909 * @since 3.1.0 910 * @since 4.5.0 The `$taxonomy` argument was made optional. 910 911 * 911 912 * @param int $term_id Term ID. 912 * @param string $taxonomy Taxonomy.913 * @param string $object_type The object type. Used to highlight the proper post type menu on the linked page.913 * @param string $taxonomy Optional. Taxonomy. Defaults to the taxonomy of the term identified by `$term_id`. 914 * @param string $object_type Optional. The object type. Used to highlight the proper post type menu on the linked page. 914 915 * Defaults to the first object_type associated with the taxonomy. 915 916 * @return string|null The edit term link URL for the given term, or null on failure. 916 917 */ 917 function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) { 918 $tax = get_taxonomy( $taxonomy ); 919 if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) { 920 return; 921 } 922 918 function get_edit_term_link( $term_id, $taxonomy = '', $object_type = '' ) { 923 919 $term = get_term( $term_id, $taxonomy ); 924 920 if ( ! $term || is_wp_error( $term ) ) { 921 return; 922 } 923 924 $tax = get_taxonomy( $term->taxonomy ); 925 if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) { 925 926 return; 926 927 } -
trunk/tests/phpunit/tests/term/getEditTermLink.php
r36309 r36646 51 51 } 52 52 53 /** 54 * @ticket 35922 55 */ 56 public function test_taxonomy_should_not_be_required() { 57 $t = self::factory()->term->create( array( 58 'taxonomy' => 'wptests_tax', 59 'name' => 'foo', 60 ) ); 53 61 62 $actual = get_edit_term_link( $t ); 63 $this->assertNotNull( $actual ); 64 } 65 66 /** 67 * @ticket 35922 68 */ 69 public function test_cap_check_should_use_correct_taxonomy_when_taxonomy_is_not_specified() { 70 register_taxonomy( 'wptests_tax_subscriber', 'post', array( 71 'manage_terms' => 'read', 72 ) ); 73 74 $t = self::factory()->term->create( array( 75 'taxonomy' => 'wptests_tax', 76 'name' => 'foo', 77 ) ); 78 79 $u = self::factory()->user->create( array( 80 'role' => 'subscriber', 81 ) ); 82 wp_set_current_user( $u ); 83 84 $actual = get_edit_term_link( $t ); 85 $this->assertNull( $actual ); 86 } 54 87 }
Note: See TracChangeset
for help on using the changeset viewer.