WordPress.org

Make WordPress Core

Ticket #35922: enhancement.35922.diff

File enhancement.35922.diff, 1.5 KB (added by nicdford, 6 years ago)
  • src/wp-includes/link-template.php

    diff --git src/wp-includes/link-template.php src/wp-includes/link-template.php
    index 3db5c28..b1458a3 100644
    function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { 
    909909 * @since 3.1.0
    910910 *
    911911 * @param int    $term_id     Term ID.
    912  * @param string $taxonomy    Taxonomy.
     912 * @param string $taxonomy    Taxonomy. Defaults to the taxonomy of the given Term ID.
    913913 * @param string $object_type The object type. Used to highlight the proper post type menu on the linked page.
    914914 *                            Defaults to the first object_type associated with the taxonomy.
    915915 * @return string|null The edit term link URL for the given term, or null on failure.
    916916 */
    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         }
     917function get_edit_term_link( $term_id, $taxonomy = '', $object_type = '' ) {
     918    $term = get_term( $term_id, $taxonomy );
     919    if ( ! $term || is_wp_error( $term ) ) {
     920        return;
     921    }
    922922
    923         $term = get_term( $term_id, $taxonomy );
    924         if ( ! $term || is_wp_error( $term ) ) {
    925                 return;
    926         }
     923    if ( ! $taxonomy ) {
     924        $taxonomy = $term->taxonomy;
     925    }
     926
     927    $tax = get_taxonomy( $taxonomy );
     928    if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) {
     929        return;
     930    }
    927931
    928932        $args = array(
    929933                'taxonomy' => $taxonomy,