Making WordPress.org

Changeset 5763


Ignore:
Timestamp:
08/07/2017 07:44:24 PM (9 years ago)
Author:
danielbachhuber
Message:

devhub/cli: First pass at retooling iA of command page

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

Legend:

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

    r5615 r5763  
    1010
    1111        <div class="entry-content">
    12                 <?php the_excerpt();
    13                 $cmd_slug = str_replace( 'wp ', '', get_the_title() );
    14                 $github_issues = 'https://github.com/issues?q=label%3A' . urlencode( 'command:' . str_replace( ' ', '-', $cmd_slug ) ) . '+sort%3Aupdated-desc+org%3Awp-cli';
    15                 ?>
    16                 <p><a class="button" href="<?php echo esc_url( $github_issues ); ?>"><?php esc_html_e( 'GitHub Issues', 'wporg' ); ?></a></p>
    1712                <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'wporg' ) ); ?>
    1813                <?php
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/cli.php

    r5761 r5763  
    266266                // Transform emdash back to triple-dashes
    267267                $content = str_replace( '&#045;&#8211;', '&#045;&#045;&#045;', $content );
     268
     269                // Include the excerpt in the main content well
     270                $excerpt = get_the_excerpt();
     271                if ( $excerpt ) {
     272                        $content = wpautop( $excerpt ) . PHP_EOL . $content;
     273                }
     274
     275                // Add 'Quick Links' across the top
     276                $items = self::get_tags( 'h([1-4])', $content );
     277                if ( count( $items ) > 1 ) {
     278                        for ( $i = 1; $i <= 4; $i++ ) {
     279                                $content = self::add_ids_and_jumpto_links( "h$i", $content );
     280                        }
     281                        $quick_links = '<p class="quick-links"><small>Quick Links: ';
     282                        foreach( $items as $item ) {
     283                                $quick_links .= '<a href="#' . sanitize_title_with_dashes( $item[3] )  . '">' . ucwords( strtolower( $item[3] ) ) . '</a> | ';
     284                        }
     285                        $quick_links = rtrim( $quick_links, ' |' ) . '</small></p>';
     286                        $content = $quick_links . PHP_EOL . PHP_EOL . $content;
     287                }
     288
    268289                return $content;
    269290        }
    270291
     292        protected static function add_ids_and_jumpto_links( $tag, $content ) {
     293                $items = self::get_tags( $tag, $content );
     294                $first = true;
     295                $matches = array();
     296                $replacements = array();
     297
     298                foreach ( $items as $item ) {
     299                        $replacement = '';
     300                        $matches[] = $item[0];
     301                        $id = sanitize_title_with_dashes($item[2]);
     302
     303                        if ( ! $first ) {
     304                                $replacement .= '<p class="toc-jump"><a href="#top">' . __( 'Top &uarr;', 'wporg' ) . '</a></p>';
     305                        } else {
     306                                $first = false;
     307                        }
     308                        $a11y_text      = sprintf( '<span class="screen-reader-text">%s</span>', $item[2] );
     309                        $anchor         = sprintf( '<a href="#%1$s" class="anchor"><span aria-hidden="true">#</span>%2$s</a>', $id, $a11y_text );
     310                        $replacement   .= sprintf( '<%1$s class="toc-heading" id="%2$s" tabindex="-1">%3$s %4$s</%1$s>', $tag, $id, $item[2], $anchor );
     311                        $replacements[] = $replacement;
     312                }
     313
     314                if ( $replacements ) {
     315                        $content = str_replace( $matches, $replacements, $content );
     316                }
     317
     318                return $content;
     319        }
     320
     321        private static function get_tags( $tag, $content ) {
     322                preg_match_all( "/(<{$tag}>)(.*)(<\/{$tag}>)/", $content, $matches, PREG_SET_ORDER );
     323                return $matches;
     324        }
     325
    271326}
    272327
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss

    r5762 r5763  
    18791879
    18801880.single-command #content {
     1881
     1882        h2, h3 {
     1883                margin-top: 3rem;
     1884                margin-bottom: 2.5rem;
     1885                font-size: 2.5rem;
     1886        }
     1887
     1888        h2.entry-title {
     1889                padding: 0;
     1890                font-size: 3.5rem;
     1891                margin-top: 3rem;
     1892                margin-bottom: 1rem;
     1893                font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
     1894                a {
     1895                        color: #000;
     1896                }
     1897        }
     1898
     1899        .quick-links {
     1900                margin-bottom: 2.5rem;
     1901        }
     1902
     1903        .toc-jump {
     1904                float: right;
     1905                font-size: 75%;
     1906        }
     1907
    18811908        table {
    18821909                border-collapse:collapse;
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css

    r5762 r5763  
    21942194}
    21952195
     2196.single-command #content h2, .single-command #content h3 {
     2197  margin-top: 3rem;
     2198  margin-bottom: 2.5rem;
     2199  font-size: 2.5rem;
     2200}
     2201
     2202.single-command #content h2.entry-title {
     2203  padding: 0;
     2204  font-size: 3.5rem;
     2205  margin-top: 3rem;
     2206  margin-bottom: 1rem;
     2207  font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
     2208}
     2209
     2210.single-command #content h2.entry-title a {
     2211  color: #000;
     2212}
     2213
     2214.single-command #content .quick-links {
     2215  margin-bottom: 2.5rem;
     2216}
     2217
     2218.single-command #content .toc-jump {
     2219  float: right;
     2220  font-size: 75%;
     2221}
     2222
    21962223.single-command #content table {
    21972224  border-collapse: collapse;
Note: See TracChangeset for help on using the changeset viewer.