Make WordPress Core

Changeset 56631


Ignore:
Timestamp:
09/20/2023 08:08:42 AM (20 months ago)
Author:
audrasjb
Message:

Taxonomy: Restrict term edit link generation in WP_Terms_List_Table::handle_row_actions().

This changeset restricts edit term link generation if the user lacks the edit_term cap in order to prevent PHP 8.1+ deprecations shown when a user lacks this
capability and get_edit_term_link() returns null.

Props thelovekesh, jrf.
Fixes #59336.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r56611 r56631  
    475475        $uri      = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
    476476
    477         $edit_link = add_query_arg(
    478             'wp_http_referer',
    479             urlencode( wp_unslash( $uri ) ),
    480             get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
    481         );
    482 
    483477        $actions = array();
    484478
     
    486480            $actions['edit'] = sprintf(
    487481                '<a href="%s" aria-label="%s">%s</a>',
    488                 esc_url( $edit_link ),
     482                esc_url(
     483                    add_query_arg(
     484                        'wp_http_referer',
     485                        urlencode( wp_unslash( $uri ) ),
     486                        get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
     487                    )
     488                ),
    489489                /* translators: %s: Taxonomy term name. */
    490490                esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $tag->name ) ),
Note: See TracChangeset for help on using the changeset viewer.