Making WordPress.org


Ignore:
Timestamp:
08/12/2014 06:26:08 AM (10 years ago)
Author:
coffee2code
Message:

Code Reference: streamline UI for archive/search listings

  • Add content-reference-archive.php template and use it for archive and search listings
  • Add wporg_filter_archive_excerpt() and use it to prefix post type label to excerpts in archive listings
  • Add wporg_filter_archive_title() and use it to append '()' to titles for function-like post types in archive listings
  • Add get_line_number() to get either start or end line number
  • Display simplified archive listing (no full method signature, no parts highlighting)
  • Add post type label, source file relative path, and start line number to archive listed items

fixes #450
props nicolealleyinteractivecom

File:
1 edited

Legend:

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

    r554 r781  
    6767}
    6868add_filter( 'wp_title', 'wporg_developer_wp_title', 10, 2 );
     69
     70/**
     71 * Prefixes excerpts for archive view with content type label.
     72 *
     73 * @param  string $excerpt The excerpt.
     74 * @return string
     75 */
     76function wporg_filter_archive_excerpt( $excerpt ) {
     77    if ( ! is_single() ) {
     78        $excerpt = '<b>' . get_post_type_labels( get_post_type_object( get_post_type( get_the_ID() ) ) )->singular_name . ': </b>' . $excerpt;
     79    }
     80
     81    return $excerpt;
     82}
     83add_filter( 'get_the_excerpt', 'wporg_filter_archive_excerpt' );
     84
     85/**
     86 * Appends parentheses to titles in archive view for functions and methods.
     87 *
     88 * @param  string $title The title.
     89 * @return string
     90 */
     91function wporg_filter_archive_title( $title ) {
     92    if ( ! is_single() && in_array( get_post_type(), array( 'wp-parser-function', 'wp-parser-method' ) ) ) {
     93        $title .= '()';
     94    }
     95
     96    return $title;
     97}
     98add_filter( 'the_title', 'wporg_filter_archive_title' );
Note: See TracChangeset for help on using the changeset viewer.