Ticket #3078: 3078.diff
File 3078.diff, 16.1 KB (added by , 5 years ago) |
---|
-
wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php
diff --git wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php wordpress.org/public_html/wp-content/plugins/wporg-meeting-posttype/wporg-meeting-posttype.php index f6cb97bf0..30b132714 100644
class Meeting_Post_Type { 30 30 add_action( 'admin_head', array( $mpt, 'meeting_column_width' ) ); 31 31 add_action( 'admin_bar_menu', array( $mpt, 'add_edit_meetings_item_to_admin_bar' ), 80 ); 32 32 add_action( 'wp_enqueue_scripts', array( $mpt, 'add_edit_meetings_icon_to_admin_bar' ) ); 33 add_shortcode( 'meeting_time', array( $mpt, 'meeting_time_shortcode' ) ); 33 34 } 34 35 35 36 public function meeting_column_width() { ?> … … class Meeting_Post_Type { 114 115 115 116 } 116 117 117 public function meeting_set_next_meeting( $posts, $query ) { 118 if ( !$query->is_post_type_archive( 'meeting' ) ) { 119 return $posts; 120 } 121 122 // for each entry, set a fake meta value to show the next date for recurring meetings 123 array_walk( $posts, function ( &$post ) { 124 if ( 'weekly' === $post->recurring || '1' === $post->recurring ) { 125 try { 126 // from the start date, advance the week until it's past now 127 $start = new DateTime( sprintf( '%s %s GMT', $post->start_date, $post->time ) ); 128 $next = $start; 129 $now = new DateTime(); 130 131 if ( $next < $now ) { 132 $interval = $start->diff( $now ); 133 // add one to days to account for events that happened earlier today 134 $weekdiff = ceil( ( $interval->days + 1 ) / 7 ); 135 $next->modify( '+ ' . $weekdiff . ' weeks' ); 136 } 137 138 $post->next_date = $next->format( 'Y-m-d' ); 139 } catch ( Exception $e ) { 140 // if the datetime is invalid, then set the post->next_date to the start date instead 141 $post->next_date = $post->start_date; 118 public function get_next_meeting( $post ) { 119 120 $next_date = null; 121 if ( 'weekly' === $post->recurring || '1' === $post->recurring ) { 122 try { 123 // from the start date, advance the week until it's past now 124 $start = new DateTime( sprintf( '%s %s GMT', $post->start_date, $post->time ) ); 125 $next = $start; 126 $now = new DateTime(); 127 128 if ( $next < $now ) { 129 $interval = $start->diff( $now ); 130 // add one to days to account for events that happened earlier today 131 $weekdiff = ceil( ( $interval->days + 1 ) / 7 ); 132 $next->modify( '+ ' . $weekdiff . ' weeks' ); 142 133 } 143 } else if ( 'biweekly' === $post->recurring ) {144 try {145 // advance the start date 2 weeks at a time until it's past now146 $start = new DateTime( sprintf( '%s %s GMT', $post->start_date, $post->time ) );147 $next = $start;148 $now = new DateTime();149 150 while ( $next < $now ) {151 $next->modify( '+2 weeks' );152 }153 134 154 $post->next_date = $next->format( 'Y-m-d' ); 155 } catch ( Exception $e ) { 156 // if the datetime is invalid, then set the post->next_date to the start date instead 157 $post->next_date = $post->start_date; 135 $next_date = $next->format( 'Y-m-d' ); 136 } catch ( Exception $e ) { 137 // if the datetime is invalid, then set the next_date to the start date instead 138 $next_date = $post->start_date; 139 } 140 } else if ( 'biweekly' === $post->recurring ) { 141 try { 142 // advance the start date 2 weeks at a time until it's past now 143 $start = new DateTime( sprintf( '%s %s GMT', $post->start_date, $post->time ) ); 144 $next = $start; 145 $now = new DateTime(); 146 147 while ( $next < $now ) { 148 $next->modify( '+2 weeks' ); 158 149 } 159 } else if ( 'occurrence' === $post->recurring ) { 160 try { 161 // advance the occurrence day in the current month until it's past now 162 $start = new DateTime( sprintf( '%s %s GMT', $post->start_date, $post->time ) ); 163 $next = $start; 164 $now = new DateTime(); 165 166 $day_index = date( 'w', strtotime( sprintf( '%s %s GMT', $post->start_date, $post->time ) ) ); 167 $day_name = $GLOBALS['wp_locale']->get_weekday( $day_index ); 168 $numerals = array( 'first', 'second', 'third', 'fourth' ); 169 $months = array( 'this month', 'next month' ); 170 171 foreach ( $months as $month ) { 172 foreach ( $post->occurrence as $index ) { 173 $next = new DateTime( sprintf( '%s %s of %s %s GMT', $numerals[ $index - 1 ], $day_name, $month, $post->time ) ); 174 if ( $next > $now ) { 175 break 2; 176 } 150 151 $next_date = $next->format( 'Y-m-d' ); 152 } catch ( Exception $e ) { 153 // if the datetime is invalid, then set the post->next_date to the start date instead 154 $next_date = $post->start_date; 155 } 156 } else if ( 'occurrence' === $post->recurring ) { 157 try { 158 // advance the occurrence day in the current month until it's past now 159 $start = new DateTime( sprintf( '%s %s GMT', $post->start_date, $post->time ) ); 160 $next = $start; 161 $now = new DateTime(); 162 163 $day_index = date( 'w', strtotime( sprintf( '%s %s GMT', $post->start_date, $post->time ) ) ); 164 $day_name = $GLOBALS['wp_locale']->get_weekday( $day_index ); 165 $numerals = array( 'first', 'second', 'third', 'fourth' ); 166 $months = array( 'this month', 'next month' ); 167 168 foreach ( $months as $month ) { 169 foreach ( $post->occurrence as $index ) { 170 $next = new DateTime( sprintf( '%s %s of %s %s GMT', $numerals[ $index - 1 ], $day_name, $month, $post->time ) ); 171 if ( $next > $now ) { 172 break 2; 177 173 } 178 174 } 179 180 $post->next_date = $next->format( 'Y-m-d' );181 } catch ( Exception $e ) {182 // if the datetime is invalid, then set the post->next_date to the start date instead183 $post->next_date = $post->start_date;184 175 } 185 } else if ( 'monthly' === $post->recurring ) {186 try {187 // advance the start date 1 month at a time until it's past now188 $start = new DateTime( sprintf( '%s %s GMT', $post->start_date, $post->time ) );189 $next = $start;190 $now = new DateTime();191 192 while ( $next < $now ) {193 $next->modify( '+1 month' );194 }195 176 196 $post->next_date = $next->format( 'Y-m-d' ); 197 } catch ( Exception $e ) { 198 // if the datetime is invalid, then set the post->next_date to the start date instead 199 $post->next_date = $post->start_date; 177 $next_date = $next->format( 'Y-m-d' ); 178 } catch ( Exception $e ) { 179 // if the datetime is invalid, then set the post->next_date to the start date instead 180 $next_date = $post->start_date; 181 } 182 } else if ( 'monthly' === $post->recurring ) { 183 try { 184 // advance the start date 1 month at a time until it's past now 185 $start = new DateTime( sprintf( '%s %s GMT', $post->start_date, $post->time ) ); 186 $next = $start; 187 $now = new DateTime(); 188 189 while ( $next < $now ) { 190 $next->modify( '+1 month' ); 200 191 } 201 } else { 202 $post->next_date = $post->start_date; 192 193 $next_date = $next->format( 'Y-m-d' ); 194 } catch ( Exception $e ) { 195 // if the datetime is invalid, then set the post->next_date to the start date instead 196 $next_date = $post->start_date; 203 197 } 198 } else { 199 $next_date = $post->start_date; 200 } 201 202 return $next_date; 203 } 204 205 public function meeting_set_next_meeting( $posts, $query ) { 206 if ( !$query->is_post_type_archive( 'meeting' ) ) { 207 return $posts; 208 } 209 210 // for each entry, set a fake meta value to show the next date for recurring meetings 211 array_walk( $posts, function ( &$post ) { 212 $post->next_date = self::get_next_meeting( $post ); 204 213 }); 205 214 206 215 // reorder the posts by next_date + time … … class Meeting_Post_Type { 462 471 ' ); 463 472 } 464 473 474 /** 475 * Renders meeting information with the next meeting time based on user's local timezone. Used in Make homepage. 476 */ 477 public function meeting_time_shortcode( $attr, $content = '' ) { 478 479 if ( empty( $attr['meeting_post_id'] ) ) { 480 return ''; 481 } 482 483 $post = (object) get_post( $attr['meeting_post_id'] ); 484 $next_meeting_datestring = self::get_next_meeting( $post ); 485 $next_meeting_iso = $next_meeting_datestring . 'T' . $post->time . ':00+00:00'; 486 $next_meeeting_timestamp = strtotime( $next_meeting_datestring . $post->time ); 487 488 $out = '<p>'; 489 $out .= __( $post->post_title ) . ': '; 490 $out .= ' <time class="date" date-time="' . esc_attr( $next_meeting_iso ) . '">' . $next_meeting_iso . '</time> '; 491 $out .= sprintf( __( '(%s from now)' ), human_time_diff( $next_meeeting_timestamp, current_time('timestamp') ) ); 492 $out .= '<br />'; 493 $out .= empty( $post->location ) ? '' : sprintf( __('%s on Slack'), $post->location ); 494 $out .= '</p>'; 495 return $out; 496 } 465 497 } 466 498 467 499 // fire it up -
wordpress.org/public_html/wp-content/themes/pub/wporg-makehome/front-page.php
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-makehome/front-page.php wordpress.org/public_html/wp-content/themes/pub/wporg-makehome/front-page.php index 72e45c759..1e0580e01 100644
8 8 <div class="wrapper"> 9 9 <h2 class="section-title"><?php _e( 'There are many different ways for you to get involved with WordPress:', 'make-wporg' ); ?></h2> 10 10 <div class="js-masonry" data-masonry-options='{ "itemSelector": ".make_site" }'> 11 <?php 11 <?php 12 12 $sites_query = new WP_Query( 'post_type=make_site&posts_per_page=-1&order=ASC' ); 13 13 $makesites = make_site_get_network_sites(); 14 14 ?> 15 15 <?php while( $sites_query->have_posts() ) : $sites_query->the_post(); ?> 16 <?php 16 <?php 17 17 $make_site_id = get_post_meta( $post->ID, 'make_site_id', true ); 18 18 $url = $makesites[$make_site_id]; 19 ?> 19 ?> 20 20 <article id="site-<?php the_ID(); ?>" <?php post_class(); ?>> 21 21 <h2> 22 22 <?php if ( $url ) : ?> 23 <a href="<?php echo esc_url( $url ); ?>"><?php the_title(); ?></a>23 <a title="<?php printf( __( 'Learn more about %s.', 'make-wporg' ), esc_html( get_the_title() ) ); ?>" href="<?php echo esc_url( $url ); ?>"><?php the_title(); ?></a> 24 24 <?php else : ?> 25 25 <?php the_title(); ?> 26 26 <?php endif; ?> 27 27 </h2> 28 28 29 29 <div class="team-description"> 30 30 <?php the_content(); ?> 31 <?php if ( $url ) : ?>32 <p><a href="<?php echo esc_url( $url ); ?>"><?php printf( __( 'Learn more about %s »', 'make-wporg' ), get_the_title() ); ?></a></p>33 <?php endif; ?>34 31 </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; /**/ ?>32 33 <div class="team-meeting"> 34 <?php 35 $meeting_post_id = get_post_meta( $post->ID, 'meeting_post_id', true ); 36 echo do_shortcode( sprintf( '[meeting_time meeting_post_id="%s"][/meeting_time]', intval( $meeting_post_id ) ) ); 37 ?> 38 </div> 42 39 </article> 43 40 <?php endwhile; ?> 44 41 </div> 45 42 </div> 46 43 </section> 47 44 45 <script type="text/javascript"> 46 47 var parse_date = function (text) { 48 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); 49 var d = new Date(); 50 d.setUTCFullYear(+m[1]); 51 d.setUTCDate(+m[3]); 52 d.setUTCMonth(+m[2]-1); 53 d.setUTCHours(+m[4]); 54 d.setUTCMinutes(+m[5]); 55 d.setUTCSeconds(+m[6]); 56 return d; 57 } 58 var format_time = function (d) { 59 return d.toLocaleTimeString(navigator.language, {weekday: 'long'}); 60 } 61 62 var nodes = document.getElementsByTagName('time'); 63 for (var i=0; i<nodes.length; ++i) { 64 var node = nodes[i]; 65 if (node.className === 'date') { 66 var d = parse_date(node.getAttribute('date-time')); 67 if (d) { 68 node.textContent = format_time(d); 69 } 70 } 71 } 72 </script> 48 73 <?php get_footer(); ?> -
wordpress.org/public_html/wp-content/themes/pub/wporg-makehome/style.css
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-makehome/style.css wordpress.org/public_html/wp-content/themes/pub/wporg-makehome/style.css index ba4628452..d65a29710 100644
section.get-involved article:nth-of-type(odd) { 203 203 clear: left; 204 204 } 205 205 206 section.get-involved article h2 :before {206 section.get-involved article h2 a:before { 207 207 font-family: 'dashicons'; 208 208 content: '\f109'; 209 209 margin-right: 0.4em; … … section.get-involved article h2:before { 214 214 -moz-osx-font-smoothing: grayscale; 215 215 } 216 216 217 section.get-involved article.make-core h2 :before { content: "\f475"; }218 section.get-involved article.make- design h2:before { content: "\f309"; }219 section.get-involved article.make- mobile h2:before { content: "\f470"; }220 section.get-involved article.make-accessibility h2 :before { content: "\f483"; }221 section.get-involved article.make-polyglots h2 :before { content: '\f326'; }222 section.get-involved article.make-support h2 :before { content: "\f125"; }223 section.get-involved article.make-themes h2 :before { content: '\f100'; }224 section.get-involved article.make-plugins h2 :before { content: '\f106'; }225 section.get-involved article.make-docs h2 :before { content: '\f105'; }226 section.get-involved article.make-community h2 :before { content: '\f307'; }227 section.get-involved article.make-meta h2 :before { content: '\f325'; }228 section.get-involved article.make-training h2 :before { content: '\f118'; }229 section.get-involved article.make-flow h2 :before { content: '\f115'; }230 section.get-involved article.make-tv h2 :before { content: '\f235'; }231 section.get-involved article.make-marketing h2 :before { content: '\f130'; }232 section.get-involved article.make-cli h2 :before { content: '\f345'; }233 section.get-involved article.make-hosting h2 :before { content: '\f176'; }234 section.get-involved article.make-tide h2 :before { content: '\f10d'; }217 section.get-involved article.make-core h2 a:before { content: "\f475"; } 218 section.get-involved article.make-mobile h2 a:before { content: "\f470"; } 219 section.get-involved article.make-design h2 a:before { content: "\f309"; } 220 section.get-involved article.make-accessibility h2 a:before { content: "\f483"; } 221 section.get-involved article.make-polyglots h2 a:before { content: '\f326'; } 222 section.get-involved article.make-support h2 a:before { content: "\f125"; } 223 section.get-involved article.make-themes h2 a:before { content: '\f100'; } 224 section.get-involved article.make-plugins h2 a:before { content: '\f106'; } 225 section.get-involved article.make-docs h2 a:before { content: '\f105'; } 226 section.get-involved article.make-community h2 a:before { content: '\f307'; } 227 section.get-involved article.make-meta h2 a:before { content: '\f325'; } 228 section.get-involved article.make-training h2 a:before { content: '\f118'; } 229 section.get-involved article.make-flow h2 a:before { content: '\f115'; } 230 section.get-involved article.make-tv h2 a:before { content: '\f235'; } 231 section.get-involved article.make-marketing h2 a:before { content: '\f130'; } 232 section.get-involved article.make-cli h2 a:before { content: '\f345'; } 233 section.get-involved article.make-hosting h2 a:before { content: '\f176'; } 234 section.get-involved article.make-tide h2 a:before { content: '\f10d'; } 235 235 236 236 section.get-involved article.featured-group h2:after { 237 237 display: block; … … section.get-involved article.featured-group h2:after { 243 243 244 244 section.get-involved article h2 a { 245 245 font-weight: 600; 246 color: #444444; 246 } 247 248 section.get-involved article h2 a { 249 font-weight: 600; 247 250 } 248 251 249 252 section.get-involved article div.team-description p { … … section.get-involved article div.team-description p { 252 255 line-height: 1.5; 253 256 } 254 257 255 section.get-involved article small{258 div.team-meeting { 256 259 display: block; 257 260 font-size: 0.8em; 258 261 font-style: italic; 259 opacity: 0. 5;262 opacity: 0.75; 260 263 padding-top: 0.5em; 261 264 } 262 265 263 section.get-involved article small p{266 section.get-involved article .team-meeting { 264 267 line-height: 1.5; 265 268 } 266 269