Making WordPress.org


Ignore:
Timestamp:
08/21/2020 05:55:20 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Consistently redirect to the referer instead of just back to the plugin page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-favorites.php

    r9666 r10196  
    6262     */
    6363    public function favorite( $request ) {
    64         $location = get_permalink( Plugin_Directory::get_plugin_post( $request['plugin_slug'] ) );
    65         header( "Location: $location" );
    66 
    67         $result = array(
    68             'location' => $location,
    69         );
     64        $plugin = Plugin_Directory::get_plugin_post( $request['plugin_slug'] );
     65        $result = [
     66            'location' => wp_get_referer() ?: get_permalink( $plugin ),
     67        ];
     68        header( 'Location: ' . $result['location'] );
    7069
    7170        if ( ! isset( $request['favorite'] ) && ! isset( $request['unfavorite'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.