Making WordPress.org

Changeset 4175


Ignore:
Timestamp:
10/01/2016 04:01:55 PM (8 years ago)
Author:
jmdodd
Message:

Support Forums: Replace spaces with underscores in Codex link shortcut.

Codex link shortcuts were incorrectly stripping spaces from the link and title rather than replacing them with an underscore.

Props SergeyBiryukov.
Fixes #2103.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-codexify/wporg-bbp-codexify.php

    r3653 r4175  
    3636
    3737    function convert_wiki_links( $content ) {
    38         if ( strpos( $content, '[[' ) && strpos( $content, ']]' ) ) {
     38        if ( strpos( $content, '[[' ) !== false && strpos( $content, ']]' ) !== false ) {
    3939            $content = preg_replace_callback( '%\[\[([ #:\/\w]+)\]\]%', array( $this, 'convert_base_wiki_link' ), $content );
    4040            $content = preg_replace_callback( '%\[\[([ #:\/\w]+)\|([^\]]+)\]\]%', array( $this, 'convert_vbar_wiki_link' ), $content );
     
    5050     */
    5151    public static function convert_base_wiki_link( $matches ) {
    52         $matches[1] = preg_replace( '/[\s]+/', '', trim( $matches[1] ) );
    53         return '<a href="' . esc_url( self::BASE_URI . strtr( $matches[1], ' ', '_' ) ) . '">' . esc_html( $matches[1] ) . '</a>';
     52        $path = preg_replace( '/[\s]+/', '_', trim( $matches[1] ) );
     53        return '<a href="' . esc_url( self::BASE_URI . $path ) . '">' . esc_html( $matches[1] ) . '</a>';
    5454    }
    5555
     
    6262     */
    6363    public static function convert_vbar_wiki_link( $matches ) {
    64         $matches[1] = preg_replace( '/[\s]+/', '_', trim( $matches[1] ) );
    65         return '<a href="' . esc_url( self::BASE_URI . strtr( $matches[1], ' ', '_' ) ) . '">' . esc_html( $matches[2] ) . '</a>';
     64        $path = preg_replace( '/[\s]+/', '_', trim( $matches[1] ) );
     65        return '<a href="' . esc_url( self::BASE_URI . $path ) . '">' . esc_html( $matches[2] ) . '</a>';
    6666    }
    6767} }
Note: See TracChangeset for help on using the changeset viewer.