Changeset 903
- Timestamp:
- 10/11/2014 05:02:27 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-components.php
r747 r903 12 12 add_action( 'wp_head', array( $this, 'wp_head' ) ); 13 13 add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) ); 14 add_action( 'component_table_row', array( $this, 'component_table_row' ) ); 14 15 $this->trac = $GLOBALS['wpdb']; 15 16 } … … 66 67 $query->set( 'orderby', 'title' ); 67 68 $query->set( 'order', 'asc' ); 68 } 69 $query->set( 'order_components', true ); 70 add_action( 'the_posts', array( $this, 'order_components_into_tree' ), 10, 2 ); 71 } 72 } 73 74 function order_components_into_tree( $posts, $query ) { 75 if ( ! $query->get( 'order_components' ) ) { 76 return $posts; 77 } 78 // Poor man's hierarchy sort 79 $parents = array_filter( wp_list_pluck( $posts, 'post_parent' ) ); 80 $new_ordering = array(); 81 foreach ( $posts as $post ) { 82 if ( $post->post_parent ) { 83 continue; 84 } 85 $new_ordering[] = $post; 86 if ( in_array( $post->ID, $parents ) ) { 87 foreach ( wp_list_filter( $posts, array( 'post_parent' => $post->ID ) ) as $child ) { 88 $new_ordering[] = $child; 89 } 90 } 91 } 92 return $new_ordering; 93 return $posts; 69 94 } 70 95 … … 156 181 ul.ticket-list li { margin-bottom: 4px } 157 182 ul.ticket-list .focus { display: inline-block; border-radius: 3px; background: #eee; padding: 2px 6px; margin-right: 4px } 158 .history.growing:before, .history.shrinking:before { font-family: Dashicons; font-size: 30px; vertical-align: top }183 .history.growing:before, .history.shrinking:before { font-family: Dashicons; font-size: 30px; vertical-align: top; line-height: 15px; float: right } 159 184 .history.growing:before { content: "\f142"; color: red } 160 185 .history.shrinking:before { content: "\f140"; color: green } 186 td.right { text-align: right; } 187 body.post-type-archive-component table td { vertical-align: middle; } 188 td.maintainers { padding-top: 4px; padding-bottom: 4px; height: 26px; } 189 td.maintainers img.avatar { margin-right: 5px; } 161 190 .component-info .create-new-ticket { float: right; margin-top: 25px; } 162 191 </style> … … 250 279 } 251 280 281 $this->maintainers_note(); 252 282 echo "\n" . "Many contributors help maintain one or more components. These maintainers are vital to keeping WordPress development running as smoothly as possible. They triage new tickets, look after existing ones, spearhead or mentor tasks, pitch new ideas, curate roadmaps, and provide feedback to other contributors. Longtime maintainers with a deep understanding of particular areas of core are always seeking to mentor others to impart their knowledge.\n\n"; 253 283 echo "<strong>Want to help? Start following this component!</strong> <a href='/core/notifications/'>Adjust your notifications here</a>. Feel free to dig into any ticket." . "\n\n"; … … 270 300 } 271 301 272 function ticket_table( $component ) { 302 303 function generate_component_breakdowns() { 304 if ( isset( $this->breakdown_component_type, $this->breakdown_component_milestone_type ) ) { 305 return; 306 } 307 273 308 $type_filled = array_fill_keys( array( 'defect (bug)', 'enhancement', 'feature request', 'task (blessed)' ), 0 ); 274 275 309 $rows = wp_cache_get( 'trac_tickets_by_component_type_milestone' ); 276 310 if ( ! $rows ) { … … 280 314 } 281 315 282 $component_type_milestone = array();283 316 foreach ( $rows as $row ) { 284 317 if ( empty( $component_type[ $row->component ] ) ) { … … 292 325 $component_milestone_type[ $row->component ][ $row->milestone ][ $row->type ] += $row->count; 293 326 } 327 328 $this->breakdown_component_type = $component_type; 329 $this->breakdown_component_milestone_type = $component_milestone_type; 330 } 331 332 function ticket_table( $component ) { 333 $this->generate_component_breakdowns(); 334 $component_type = $this->breakdown_component_type; 335 $component_milestone_type = $this->breakdown_component_milestone_type; 294 336 295 337 if ( is_singular() ) { … … 486 528 $components = $this->trac->get_col( "SELECT name FROM component" ); 487 529 foreach ( $components as $component ) { 488 echo '<option value="component/' . esc_attr( urlencode($component ) ) . '">' . esc_html( $component ) . "</option>";530 echo '<option value="component/' . esc_attr( str_replace( ' ', '+', $component ) ) . '">' . esc_html( $component ) . "</option>"; 489 531 } 490 532 } … … 492 534 return ob_get_clean(); 493 535 } 536 537 function component_table_row( $post ) { 538 static $once = true; 539 if ( $once ) { 540 $once = false; 541 echo '<thead><tr><th>Component</th><th style="width: 50px">Tickets</th><th style="width: 50px">7 Days</th><th>Maintainers</th></tr></thead>'; 542 } 543 544 $component = $post->post_title; 545 $this->generate_component_breakdowns(); 546 $history = $this->get_component_history( $component ); 547 548 $arrow = ''; 549 if ( $history['change'] ) { 550 $direction = $history['change'] > 0 ? 'growing' : 'shrinking'; 551 $arrow = '<span class="history ' . $direction . '"></span>'; 552 } 553 554 echo '<tr>'; 555 if ( $post->post_parent ) { 556 echo '<td>— <a href="' . get_permalink() . '">' . $post->post_title . '</a></td>'; 557 } else { 558 echo '<td><a href="' . get_permalink() . '"><strong>' . $post->post_title . '</strong></a></td>'; 559 } 560 561 $open_tickets = array_sum( $this->breakdown_component_type[ $component ] ); 562 echo '<td class="right"><a href="https://core.trac.wordpress.org/component/' . esc_attr( str_replace( ' ', '+', $component ) ) . '">' . $open_tickets . '</a></td>'; 563 if ( $history['change'] ) { 564 echo '<td class="right">' . $arrow . ' ' . sprintf( "%+d", $history['change'] ) . '</td>'; 565 } else { 566 echo '<td></td>'; 567 } 568 569 $maintainers = get_post_meta( $post->ID, '_active_maintainers', true ); 570 $maintainers = array_filter( array_map( 'trim', explode( ',', $maintainers ) ) ); 571 echo '<td class="no-grav maintainers">'; 572 foreach ( $maintainers as $maintainer ) { 573 echo '<a href="//profiles.wordpress.org/' . esc_attr( $maintainer ) . '" title="' . esc_attr( $maintainer ) . '">' . get_avatar( get_user_by( 'login', $maintainer )->user_email, 24 ) . "</a>"; 574 } 575 echo '</td>'; 576 echo '</tr>'; 577 } 494 578 } 495 579 new Make_Core_Trac_Components;
Note: See TracChangeset
for help on using the changeset viewer.