Make WordPress Core


Ignore:
Timestamp:
03/24/2025 11:57:08 PM (3 months ago)
Author:
audrasjb
Message:

REST API: exclude rest_route from get_params() if pretty permalinks are disabled.

This changeset introduces a modification to the get_params() method within the WordPress REST API. The change ensures that the rest_route parameter is excluded from the parameters returned when pretty permalinks are not enabled. This update enhances the developer experience by ensuring that the parameters returned by get_params() are relevant and do not include unnecessary values, thereby reducing potential confusion and errors.

Props westonruter, TimothyBlynJacobs, audrasjb, debarghyabanerjee, dilip2615, shanemuir, peterwilsoncc.
Fixes #62163.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-request.php

    r59899 r60073  
    495495        }
    496496
     497        // Exclude rest_route if pretty permalinks are not enabled.
     498        if ( ! get_option( 'permalink_structure' ) ) {
     499            unset( $params['rest_route'] );
     500        }   
     501
    497502        return $params;
    498503    }
Note: See TracChangeset for help on using the changeset viewer.