Making WordPress.org


Ignore:
Timestamp:
12/19/2016 07:00:06 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: Allow us to return the FAQ section with <h4> instead of <dl> for existing WordPress versions.
Also fixes the hot_tags endpoint to work correctly.

See #2112.

File:
1 edited

Legend:

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

    r4505 r4559  
    112112        }
    113113        $result['sections']['reviews'] = $this->get_plugin_reviews_markup( $post->post_name );
     114        if ( !empty( $result['sections']['faq'] ) ) {
     115            $result['sections']['enhanced_faq'] = $result['sections']['faq'];
     116            $result['sections']['faq'] = $this->get_simplified_faq_markup( $result['sections']['enhanced_faq'] );
     117        }
     118       
    114119        $result['description'] = $result['sections']['description'];
    115120
     
    271276    }
    272277
     278    /**
     279     * Return a 'simplified' markup for the FAQ screen.
     280     * WordPress only supports a whitelisted selection of tags, `<dl>` is not one of them.
     281     *
     282     * @see https://core.trac.wordpress.org/browser/tags/4.7/src/wp-admin/includes/plugin-install.php#L478
     283     * @param string $markup The existing Markup.
     284     * @return string Them markup with `<dt>` replaced with `<h4>` and `<dd>` with `<p>`.
     285     */
     286    protected function get_simplified_faq_markup( $markup ) {
     287        $markup = str_replace(
     288            array( '<dl>', '</dl>', '<dt>', '</dt>', '<dd>', '</dd>' ),
     289            array( '',      '',     '<h4>', '</h4>', '<p>',  '</p>'  ),
     290            $markup
     291        );
     292
     293        return $markup;
     294    }
     295
    273296}
    274297
Note: See TracChangeset for help on using the changeset viewer.