Making WordPress.org

Ticket #3035: 3035.4.diff

File 3035.4.diff, 3.5 KB (added by Kau-Boy, 7 years ago)

Changed the session categories slug to use a dash instead of an underscore

  • wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php

    diff --git wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php
    index e53ea67..9fcc325 100644
    function wcorg_content_slugs_to_body_tag( $body_classes ) { 
    203203}
    204204add_filter( 'body_class', 'wcorg_content_slugs_to_body_tag' );
    205205
     206
     207/**
     208 * Add the sessions's category slugs to the body tag
     209 *
     210 * @param array $body_classes
     211 *
     212 * @return array
     213 */
     214function wcorg_session_category_slugs_to_body_tag( $body_classes ) {
     215        global $wp_query;
     216        $post = $wp_query->get_queried_object();
     217
     218        if ( is_a( $post, 'WP_Post' ) && 'wcb_session' === $post->post_type ) {
     219                $session_categories   = get_the_terms( $post->ID, 'wcb_session_category' );
     220
     221                if ( is_array( $session_categories ) ) {
     222                        foreach ( $session_categories as $session_category ) {
     223                                $body_classes[] = 'wcb-session-category-' . $session_category->slug;
     224                        }
     225                }
     226        }
     227
     228        return $body_classes;
     229}
     230add_filter( 'body_class', 'wcorg_session_category_slugs_to_body_tag' );
     231
    206232/*
    207233 * Flush the rewrite rules on the current site.
    208234 *
  • wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    diff --git wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php
    index 503bbff..225ca94 100644
    class WordCamp_Post_Types_Plugin { 
    5454                add_filter( 'the_content', array( $this, 'add_speaker_info_to_session_posts' ) );
    5555                add_filter( 'the_content', array( $this, 'add_slides_info_to_session_posts' ) );
    5656                add_filter( 'the_content', array( $this, 'add_video_info_to_session_posts' ) );
     57                add_filter( 'the_content', array( $this, 'add_session_categories_to_session_posts' ) );
    5758                add_filter( 'the_content', array( $this, 'add_session_info_to_speaker_posts' ) );
    5859
    5960                add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ) );
    class WordCamp_Post_Types_Plugin { 
    14131414        }
    14141415
    14151416        /**
     1417         * Add session's categories to Session posts
     1418         *
     1419         * @param string $content
     1420         *
     1421         * @return string
     1422         */
     1423        function add_session_categories_to_session_posts( $content ) {
     1424                global $post;
     1425
     1426                if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) {
     1427                        return $content;
     1428                }
     1429
     1430                $session_categories_html = '';
     1431
     1432                $session_categories_list = get_the_term_list( $post->ID, 'wcb_session_category', '', _x( ', ', 'Used between list items, there is a space after the comma.', 'wordcamporg' ) );
     1433                if ( $session_categories_list ) {
     1434                        $session_categories_html = sprintf( '<span class="session-categories-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
     1435                                _x( 'Categories', 'Used before session category names.', 'wordcamporg' ),
     1436                                $session_categories_list
     1437                        );
     1438                }
     1439
     1440                return $content . $session_categories_html;
     1441        }
     1442
     1443        /**
    14161444         * Add session information to Speaker posts
    14171445         *
    14181446         * We don't enable it for sites that were created before it was committed, because some will have already
    class WordCamp_Post_Types_Plugin { 
    21462174                // Register the Categories taxonomy.
    21472175                register_taxonomy( 'wcb_session_category', 'wcb_session', array(
    21482176                        'labels'       => $labels,
    2149                         'rewrite'      => array( 'slug' => 'session_category' ),
     2177                        'rewrite'      => array( 'slug' => 'session-category' ),
    21502178                        'query_var'    => 'session_category',
    21512179                        'hierarchical' => true,
    21522180                        'public'       => true,