WordPress.org

Making WordPress.org

Changeset 6302


Ignore:
Timestamp:
12/21/2017 05:45:50 PM (6 months ago)
Author:
SergeyBiryukov
Message:

Support Theme: Simplify wporg_support_get_views().

File:
1 edited

Legend:

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

    r6178 r6302  
    111111 */
    112112function wporg_support_get_views() {
    113     $all = bbp_get_views();
    114     $ordered = array(
     113    $views = array(
    115114        'all-topics',
    116115        'no-replies',
     
    118117        'taggedmodlook',
    119118    );
    120     $found = array();
    121     foreach ( $ordered as $view ) {
    122         if ( array_key_exists( $view, $all ) ) {
    123             $found[] = $view;
     119
     120    $output = array();
     121
     122    foreach ( $views as $view ) {
     123        if ( ! bbp_get_view_id( $view ) ) {
     124            continue;
    124125        }
    125     }
    126     $view_iterator = 0;
    127     $view_count    = count( $found );
    128 
    129     foreach ( $found as $view ) : $view_iterator++; ?>
    130 
    131         <li class="view"><a href="<?php bbp_view_url( $view ); ?>"><?php bbp_view_title( $view ); ?></a></li>
    132 
    133         <?php if ( $view_iterator < $view_count ) : ?>|<?php endif; ?>
    134 
    135     <?php endforeach;
    136 
    137     // Unset variables
    138     unset( $view_count, $view_iterator, $view, $found, $all, $ordered );
     126
     127        $output[] = sprintf( '<li class="view"><a href="%s">%s</a></li>',
     128            esc_url( bbp_get_view_url( $view ) ),
     129            bbp_get_view_title( $view )
     130        );
     131    }
     132
     133    echo implode( ' | ', $output );
    139134}
    140135
Note: See TracChangeset for help on using the changeset viewer.