Making WordPress.org


Ignore:
Timestamp:
11/11/2016 09:44:06 PM (10 years ago)
Author:
iandunn
Message:

WordCamp Post Types: Add a taxonomy for organizer teams

Fixes #2159
Props Kau-Boy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    r4172 r4349  
    405405                        'posts_per_page' => -1,
    406406                        'orderby'        => 'date',
     407                        'teams'          => '',
    407408                ), $attr );
    408409
     
    411412                $attr['orderby'] = ( in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ) ? $attr['orderby'] : 'date';
    412413
    413                 $organizers = new WP_Query( array(
     414                $query_args = array(
    414415                        'post_type' => 'wcb_organizer',
    415416                        'posts_per_page' => intval( $attr['posts_per_page'] ),
    416417                        'orderby' => $attr['orderby'],
    417                 ) );
     418                );
     419
     420                if ( ! empty( $attr['teams'] ) ) {
     421                        $query_args['tax_query'] = array(
     422                                array(
     423                                        'taxonomy' => 'wcb_organizer_team',
     424                                        'field'    => 'slug',
     425                                        'terms'    => explode( ',', $attr['teams'] ),
     426                                ),
     427                        );
     428                }
     429
     430                $organizers = new WP_Query( $query_args );
    418431
    419432                if ( ! $organizers->have_posts() )
     
    20042017                        'show_ui'               => true,
    20052018                ) );
     2019
     2020                // Labels for organizer teams.
     2021                $labels = array(
     2022                        'name'          => __( 'Teams',         'wordcamporg' ),
     2023                        'singular_name' => __( 'Team',          'wordcamporg' ),
     2024                        'search_items'  => __( 'Search Teams',  'wordcamporg' ),
     2025                        'popular_items' => __( 'Popular Teams', 'wordcamporg' ),
     2026                        'all_items'     => __( 'All Teams',     'wordcamporg' ),
     2027                        'edit_item'     => __( 'Edit Team',     'wordcamporg' ),
     2028                        'update_item'   => __( 'Update Team',   'wordcamporg' ),
     2029                        'add_new_item'  => __( 'Add Team',      'wordcamporg' ),
     2030                        'new_item_name' => __( 'New Team',      'wordcamporg' ),
     2031                );
     2032
     2033                // Register organizer teams taxonomy
     2034                register_taxonomy(
     2035                        'wcb_organizer_team',
     2036                        'wcb_organizer',
     2037                        array(
     2038                                'labels'       => $labels,
     2039                                'rewrite'      => array( 'slug' => 'team' ),
     2040                                'query_var'    => 'team',
     2041                                'hierarchical' => true,
     2042                                'public'       => true,
     2043                                'show_ui'      => true,
     2044                        )
     2045                );
    20062046        }
    20072047
Note: See TracChangeset for help on using the changeset viewer.