Making WordPress.org

Changeset 781


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

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
Files:
1 added
7 edited

Legend:

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

    r591 r781  
    2323                <?php while ( have_posts() ) : the_post(); ?>
    2424
    25                     <?php
    26                         /* Include the Post-Format-specific template for the content.
    27                          * If you want to override this in a child theme, then include a file
    28                          * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    29                          */
    30                         get_template_part( 'content', 'reference' );
    31                     ?>
     25                    <?php get_template_part( 'content', 'reference-archive' ); ?>
    3226
    3327                <?php endwhile; ?>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/header.php

    r554 r781  
    1010?>
    1111
    12 <div id="page" class="hfeed site devhub-wrap">
     12<div id="page" <?php body_class( 'hfeed site devhub-wrap' ); ?>>
    1313    <?php do_action( 'before' ); ?>
    1414    <header id="masthead" class="site-header" role="banner">
  • 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' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r773 r781  
    623623
    624624    /**
     625     * Retrieve either the starting or ending line number.
     626     *
     627     * @param  int    $post_id Optional. The post ID.
     628     * @param  string $type    Optional. Either 'start' for starting line number, or 'end' for ending line number.
     629     *
     630     * @return int
     631     */
     632    function get_line_number( $post_id = null, $type = 'start' ) {
     633
     634        $post_id  = empty( $post_id ) ? get_the_ID() : $post_id;
     635        $meta_key = ( 'end' == $type ) ? '_wp-parser_end_line_num' : '_wp-parser_line_num';
     636
     637        return (int) get_post_meta( $post_id, $meta_key, true );
     638    }
     639
     640    /**
    625641     * Retrieve the URL to the actual source file and line.
    626642     *
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss

    r780 r781  
    883883    }
    884884
     885    &.archive, &.search {
     886        .wp-parser-class, .wp-parser-function, .wp-parser-hook, .wp-parser-method {
     887            h1 {
     888                a {
     889                    font-family: $body-font;
     890                    color: #21759b;
     891                    font-weight: normal;
     892                }
     893            }
     894            div {
     895                &.sourcefile {
     896                    color: #999999;
     897                    font-style: italic;
     898                }
     899            }
     900        }
     901    }
     902
    885903    .single {
    886904        .wp-parser-class, .wp-parser-function, .wp-parser-hook, .wp-parser-method {
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/search.php

    r742 r781  
    2424            <?php while ( have_posts() ) : the_post(); ?>
    2525
    26                 <?php get_template_part( 'content', 'reference' ); ?>
     26                <?php get_template_part( 'content', 'reference-archive' ); ?>
    2727
    2828            <?php endwhile; ?>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css

    r780 r781  
    10941094  padding: 20px;
    10951095}
     1096.devhub-wrap.archive .wp-parser-class h1 a, .devhub-wrap.archive .wp-parser-function h1 a, .devhub-wrap.archive .wp-parser-hook h1 a, .devhub-wrap.archive .wp-parser-method h1 a, .devhub-wrap.search .wp-parser-class h1 a, .devhub-wrap.search .wp-parser-function h1 a, .devhub-wrap.search .wp-parser-hook h1 a, .devhub-wrap.search .wp-parser-method h1 a {
     1097  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
     1098  color: #21759b;
     1099  font-weight: normal;
     1100}
     1101.devhub-wrap.archive .wp-parser-class div.sourcefile, .devhub-wrap.archive .wp-parser-function div.sourcefile, .devhub-wrap.archive .wp-parser-hook div.sourcefile, .devhub-wrap.archive .wp-parser-method div.sourcefile, .devhub-wrap.search .wp-parser-class div.sourcefile, .devhub-wrap.search .wp-parser-function div.sourcefile, .devhub-wrap.search .wp-parser-hook div.sourcefile, .devhub-wrap.search .wp-parser-method div.sourcefile {
     1102  color: #999999;
     1103  font-style: italic;
     1104}
    10961105.devhub-wrap .single .wp-parser-class, .devhub-wrap .single .wp-parser-function, .devhub-wrap .single .wp-parser-hook, .devhub-wrap .single .wp-parser-method {
    10971106  border-bottom-style: none;
Note: See TracChangeset for help on using the changeset viewer.