Making WordPress.org

Changeset 2206


Ignore:
Timestamp:
12/18/2015 06:15:42 PM (9 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Allow use of 'code' tags (generally added by parser through use of backticks in source) in parameter descriptions.

  • Allow use of 'code' tags in parameter descriptions (by unencoding the tag).
  • Consolidate parameter description formatting into DevHub_Formatting::format_param_description().
Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/formatting.php

    r1914 r2206  
    195195    }
    196196
     197    /**
     198     * Handles formatting of the parameter description.
     199     *
     200     * @param  string $text The parameter description.
     201     * @return string
     202     */
     203    public static function format_param_description( $text ) {
     204        // Encode all htmlentities.
     205        $text = htmlentities( $text );
     206
     207        // Simple allowable tags that should get unencoded.
     208        // Note: This precludes them from being able to be used in an encoded fashion
     209        // within a parameter description.
     210        $allowable_tags = array( 'code' );
     211        foreach ( $allowable_tags as $tag ) {
     212            $text = str_replace( array( "&lt;{$tag}&gt;", "&lt;/{$tag}&gt;" ), array( "<{$tag}>", "</{$tag}>" ), $text );
     213        }
     214
     215        // Convert any @link or @see to actual link.
     216        $text = self::make_doclink_clickable( $text );
     217
     218        return $text;
     219    }
     220
    197221} // DevHub_Formatting
    198222
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r2205 r2206  
    633633                        $params[ $tag['variable'] ]['required'] = 'Required';
    634634                    }
    635                     $params[ $tag['variable'] ]['content'] = htmlentities( $params[ $tag['variable'] ]['content'] );
    636                     $params[ $tag['variable'] ]['content'] = \DevHub_Formatting::make_doclink_clickable( $params[ $tag['variable'] ]['content'] );
     635                    $params[ $tag['variable'] ]['content'] = \DevHub_Formatting::format_param_description( $params[ $tag['variable'] ]['content'] );
    637636                }
    638637            }
Note: See TracChangeset for help on using the changeset viewer.