Making WordPress.org


Ignore:
Timestamp:
06/05/2019 07:10:22 AM (7 years ago)
Author:
tellyworth
Message:

Make home theme: show next meeting time in user's TZ.

This uses the shortcode from [8922] to display the next meeting for each team, with a link to find additional meetings, rather than a single "Weekly" meeting per team. JS is used to convert the time into the user's local time zone. It also links to a filtered list of meetings per team.

Props ck3lee.
Fixes #3078.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-makehome/front-page.php

    r2225 r8923  
    99                <h2 class="section-title"><?php _e( 'There are many different ways for you to get involved with WordPress:', 'make-wporg' ); ?></h2>
    1010                <div class="js-masonry" data-masonry-options='{ "itemSelector": ".make_site" }'>
    11                 <?php 
     11                <?php
    1212                        $sites_query = new WP_Query( 'post_type=make_site&posts_per_page=-1&order=ASC' );
    1313                        $makesites = make_site_get_network_sites();
    1414                ?>
    15                 <?php while( $sites_query->have_posts() ) : $sites_query->the_post(); ?>
    16                 <?php
    17                         $make_site_id = get_post_meta( $post->ID, 'make_site_id', true );
    18                         $url = $makesites[$make_site_id];
    19                 ?>     
     15                <?php while ( $sites_query->have_posts() ) : $sites_query->the_post(); ?>
     16                        <?php
     17                                $make_site_id = get_post_meta( $post->ID, 'make_site_id', true );
     18                                $url          = $makesites[ $make_site_id ];
     19                ?>
    2020                        <article id="site-<?php the_ID(); ?>" <?php post_class(); ?>>
    2121                                <h2>
    2222                                        <?php if ( $url ) : ?>
    23                                                 <a href="<?php echo esc_url( $url ); ?>"><?php the_title(); ?></a>
     23                                                <a
     24                                                        title="<?php printf( esc_attr( 'Learn more about %s.', 'make-wporg' ), esc_html( get_the_title() ) ); ?>"
     25                                                        href="<?php echo esc_url( $url ); ?>"
     26                                                ><?php the_title(); ?></a>
    2427                                        <?php else : ?>
    2528                                                <?php the_title(); ?>
    2629                                        <?php endif; ?>
    2730                                </h2>
    28                                
     31
    2932                                <div class="team-description">
    3033                                        <?php the_content(); ?>
    31                                         <?php if ( $url ) : ?>
    32                                                 <p><a href="<?php echo esc_url( $url ); ?>"><?php printf( __( 'Learn more about %s &raquo;', 'make-wporg' ), get_the_title() ); ?></a></p>
    33                                         <?php endif; ?>
    3434                                </div>
    35                                
    36                                 <?php  if ( '1' == get_post_meta( get_the_ID(), 'weekly_meeting', true ) ) : ?>
    37                                         <small>
    38                                                 <p><?php printf( __( 'Weekly chats: %s', 'make-wporg' ), get_post_meta( get_the_ID(), 'weekly_meeting_when', true ) ); ?></p>
    39                                                 <p><?php echo get_post_meta( get_the_ID(), 'weekly_meeting_where', true ); ?></p>
    40                                         </small>
    41                                 <?php endif; /**/ ?>
     35
     36                                <div class="team-meeting">
     37                                        <?php
     38                                                echo do_shortcode( sprintf( '[meeting_time team="%s"][/meeting_time]', $post->post_title ) );
     39                                        ?>
     40                                </div>
    4241                        </article>
    4342                <?php endwhile; ?>
     
    4645</section>
    4746
     47<script type="text/javascript">
     48
     49        var parse_date = function (text) {
     50                var m = /^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})\+00:00$/.exec(text);
     51                var d = new Date();
     52                d.setUTCFullYear(+m[1]);
     53                d.setUTCDate(+m[3]);
     54                d.setUTCMonth(+m[2]-1);
     55                d.setUTCHours(+m[4]);
     56                d.setUTCMinutes(+m[5]);
     57                d.setUTCSeconds(+m[6]);
     58                return d;
     59        }
     60        var format_time = function (d) {
     61                return d.toLocaleTimeString(navigator.language, {weekday: 'long', hour: '2-digit', minute: '2-digit'});
     62        }
     63
     64        var nodes = document.getElementsByTagName('time');
     65        for (var i=0; i<nodes.length; ++i) {
     66                var node = nodes[i];
     67                if (node.className === 'date') {
     68                        var d = parse_date(node.getAttribute('date-time'));
     69                        if (d) {
     70                                node.textContent = format_time(d);
     71                        }
     72                }
     73        }
     74</script>
    4875<?php get_footer(); ?>
Note: See TracChangeset for help on using the changeset viewer.