Making WordPress.org

Changeset 5546


Ignore:
Timestamp:
06/07/2017 12:43:23 AM (7 years ago)
Author:
coreymckrill
Message:

WordCamp Post Types: Add groups taxonomy to Speakers PT

Adds the wcb_speaker_group taxonomy to the wcb_speaker post type.
Makes the new taxonomy available in the v2 REST API speakers endpoint.
Also adds the groups parameter to the [speakers] shortcode, so that
the list of output speakers can be filtered by one or more groups.

Props Kau-Boy, coreymckrill
Fixes #2850

File:
1 edited

Legend:

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

    r5545 r5546  
    282282            'track'          => '',
    283283            'speaker_link'   => '',
     284            'groups'         => '',
    284285        ), $attr );
    285286
     
    293294        $attr['speaker_link'] = in_array( $attr['speaker_link'], array( 'permalink'             ) ) ? $attr['speaker_link'] : '';
    294295        $attr['track']        = array_map( 'trim', explode( ',', $attr['track'] ) );
     296        $attr['groups']       = array_map( 'trim', explode( ',', $attr['groups'] ) );
    295297
    296298        // Fetch all the relevant sessions
     
    346348        if ( ! empty( $attr['track'] ) ) {
    347349            $speaker_args['post__in'] = $speaker_ids;
     350        }
     351
     352        if ( ! empty( $attr['groups'] ) ) {
     353            $speaker_args['tax_query'] = array(
     354                array(
     355                    'taxonomy' => 'wcb_speaker_group',
     356                    'field'    => 'slug',
     357                    'terms'    => $attr['groups'],
     358                ),
     359            );
    348360        }
    349361
     
    20572069            )
    20582070        );
     2071
     2072        // Labels for speaker groups.
     2073        $labels = array(
     2074            'name'          => __( 'Groups',         'wordcamporg' ),
     2075            'singular_name' => __( 'Group',          'wordcamporg' ),
     2076            'search_items'  => __( 'Search Groups',  'wordcamporg' ),
     2077            'popular_items' => __( 'Popular Groups', 'wordcamporg' ),
     2078            'all_items'     => __( 'All Groups',     'wordcamporg' ),
     2079            'edit_item'     => __( 'Edit Group',     'wordcamporg' ),
     2080            'update_item'   => __( 'Update Group',   'wordcamporg' ),
     2081            'add_new_item'  => __( 'Add Group',      'wordcamporg' ),
     2082            'new_item_name' => __( 'New Group',      'wordcamporg' ),
     2083        );
     2084
     2085        // Register speaker groups taxonomy
     2086        register_taxonomy(
     2087            'wcb_speaker_group',
     2088            'wcb_speaker',
     2089            array(
     2090                'labels'       => $labels,
     2091                'rewrite'      => array( 'slug' => 'speaker_group' ),
     2092                'query_var'    => 'speaker_group',
     2093                'hierarchical' => true,
     2094                'public'       => true,
     2095                'show_ui'      => true,
     2096                'show_in_rest' => true,
     2097                'rest_base'    => 'speaker_group',
     2098            )
     2099        );
    20592100    }
    20602101
Note: See TracChangeset for help on using the changeset viewer.