Making WordPress.org


Ignore:
Timestamp:
08/30/2016 06:27:46 PM (8 years ago)
Author:
jmdodd
Message:

Forums Theme: Simplify view stack for easier display.

File:
1 edited

Legend:

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

    r3798 r3883  
    8989/**
    9090 * Register these bbPress views:
    91  *  View: All Topics
    92  *  @ToDo View: Not Resolved
    93  *  @ToDo View: modlook
     91 *  View: All topics
     92 *  View: Tagged modlook
    9493 *
    9594 * @uses bbp_register_view() To register the view
    9695 */
    9796function wporg_support_custom_views() {
    98     bbp_register_view( 'all-topics', __( 'All Topics', 'wporg-forums' ), array( 'order' => 'DESC' ), false );
    99 //  bbp_register_view( 'support-forum-no', __( 'Not Resolved', 'wporg-forums' ), array( 'post_status' => 'closed' ), false );
    100 //  bbp_register_view( 'taggedmodlook', __( 'Tagged modlook', 'wporg-forums' ), array( 'topic-tag' => 'modlook' ) );
     97    bbp_register_view( 'all-topics', __( 'All topics', 'wporg-forums' ), array( 'order' => 'DESC' ), false );
     98    if ( get_current_user_id() && current_user_can( 'moderate' ) ) {
     99        bbp_register_view( 'taggedmodlook', __( 'Tagged modlook', 'wporg-forums' ), array( 'topic-tag' => 'modlook' ) );
     100    }
    101101}
    102102add_action( 'bbp_register_views', 'wporg_support_custom_views' );
     103
     104/**
     105 * Display an ordered list of bbPress views
     106 */
     107function wporg_support_get_views() {
     108    $all = bbp_get_views();
     109    $ordered = array(
     110        'all-topics',
     111        'no-replies',
     112        'support-forum-no',
     113        'taggedmodlook',
     114    );
     115    $found = array();
     116    foreach ( $ordered as $view ) {
     117        if ( array_key_exists( $view, $all ) ) {
     118            $found[] = $view;
     119        }
     120    }
     121    $view_iterator = 0;
     122    $view_count    = count( $found );
     123
     124    foreach ( $found as $view ) : $view_iterator++; ?>
     125
     126        <li class="view"><a href="<?php bbp_view_url( $view ); ?>"><?php bbp_view_title( $view ); ?></a></li>
     127
     128        <?php if ( $view_iterator < $view_count ) : ?>|<?php endif; ?>
     129
     130    <?php endforeach;
     131
     132    // Unset variables
     133    unset( $view_count, $view_iterator, $view, $found, $all, $ordered );
     134}
    103135
    104136/**
Note: See TracChangeset for help on using the changeset viewer.