Make WordPress Core


Ignore:
Timestamp:
06/17/2021 11:28:55 AM (4 years ago)
Author:
SergeyBiryukov
Message:

REST API: Decode HTML entities in widget names and descriptions in widget types controller.

Follow-up to [50995].

Props ramonopoly, noisysocks, spacedmonkey, justinahinon, audrasjb, SergeyBiryukov.
Fixes #53407.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-widget-types-controller.php

    r51137 r51174  
    200200
    201201    /**
     202     * @ticket 53407
     203     */
     204    public function test_get_widgets_decodes_html_entities() {
     205        wp_set_current_user( self::$admin_id );
     206        $widget_id = 'archives';
     207        wp_register_sidebar_widget(
     208            $widget_id,
     209            'Legacy ‑ Archive ‑ Widget',
     210            function() {},
     211            array(
     212                'description' => 'A great & interesting archive of your site’s posts!',
     213            )
     214        );
     215        $request  = new WP_REST_Request( 'GET', '/wp/v2/widget-types/archives' );
     216        $response = rest_get_server()->dispatch( $request );
     217        $data     = $response->get_data();
     218        $this->assertSame( 'Legacy ‑ Archive ‑ Widget', $data['name'] );
     219        $this->assertSame( 'A great & interesting archive of your site’s posts!', $data['description'] );
     220    }
     221
     222    /**
    202223     * @ticket 41683
    203224     */
     
    493514    }
    494515
    495 
    496516    /**
    497517     * The test_create_item() method does not exist for widget types.
Note: See TracChangeset for help on using the changeset viewer.