Changeset 6770
- Timestamp:
- 02/26/2018 08:14:23 PM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins
- Files:
-
- 3 edited
-
wporg-gp-customizations/templates/locale-project.php (modified) (2 diffs)
-
wporg-gp-customizations/templates/style.css (modified) (2 diffs)
-
wporg-gp-routes/inc/routes/class-locale.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/locale-project.php
r6694 r6770 259 259 </div> 260 260 261 <?php if ( $locale_contributors['editors'] ) : ?> 262 <div class="locale-project-contributors-group locale-project-contributors-editors"> 263 <h3>Translation Editors</h3> 264 <small>These users can validate and approve your translations.</small> 265 <br><br> 261 <div class="locale-project-contributors-group locale-project-contributors-editors"> 262 <h3>Translation Editors</h3> 263 <?php 264 if ( $locale_contributors['editors']['project'] ) : 265 ?> 266 <p>These users can validate and approve your translations for this specific project.</p> 266 267 <ul> 267 268 <?php 268 foreach ( $locale_contributors['editors'] as $editor ) {269 foreach ( $locale_contributors['editors']['project'] as $editor ) { 269 270 printf( 270 271 '<li><a href="https://profiles.wordpress.org/%s/">%s %s</a></li>', … … 276 277 ?> 277 278 </ul> 278 </div> 279 <?php endif; ?> 279 <?php 280 else : 281 ?> 282 <p>There are no editors for this specific project, yet. <a href="https://make.wordpress.org/polyglots/handbook/rosetta/theme-plugin-directories/">Become an editor.</a></p> 283 <?php 284 endif; 285 286 if ( $locale_contributors['editors']['inherited'] ) : 287 ?> 288 <hr> 289 <p>The following users can edit translations for either a parent project or all projects.</p> 290 <ul class="compressed"> 291 <?php 292 foreach ( $locale_contributors['editors']['inherited'] as $editor ) { 293 printf( 294 '<li><a href="https://profiles.wordpress.org/%s/">%s %s</a></li>', 295 $editor->nicename, 296 get_avatar( $editor->email, 15 ), 297 $editor->display_name ? $editor->display_name : $editor->nicename 298 ); 299 } 300 ?> 301 </ul> 302 <?php 303 endif; 304 ?> 305 </div> 280 306 </div> 281 307 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css
r6742 r6770 1641 1641 } 1642 1642 1643 .locale-project-contributors-group hr { 1644 margin: 30px 0; 1645 } 1646 1643 1647 .locale-project-contributors-group ul { 1644 1648 padding: 0; 1645 margin: 0;1649 margin: 10px 0; 1646 1650 list-style: none; 1647 1651 } … … 1654 1658 vertical-align: middle; 1655 1659 margin-right: 10px; 1660 } 1661 1662 .locale-project-contributors-group ul.compressed li { 1663 display: inline-block; 1664 margin-right: 8px; 1665 font-size: small; 1666 } 1667 1668 .locale-project-contributors-group ul.compressed li:not(:last-child):after { 1669 content: ', '; 1670 } 1671 1672 .locale-project-contributors-group ul.compressed .avatar { 1673 margin-right: 3px; 1656 1674 } 1657 1675 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-locale.php
r6692 r6770 372 372 global $wpdb; 373 373 374 $editors = [ 375 'project' => [], 376 'inherited' => [], 377 ]; 378 374 379 // Get the translation editors of the project. 375 $editors = (array) $wpdb->get_col( $wpdb->prepare( "380 $editors['project'] = (array) $wpdb->get_col( $wpdb->prepare( " 376 381 SELECT 377 382 `user_id` … … 382 387 ", $project->id, $locale_slug ) ); 383 388 389 // Get the translation editors of parent projects. 384 390 if ( $project->parent_project_id ) { 385 391 $parent_project_id = $project->parent_project_id; 386 392 $parent_project = GP::$project->get( $parent_project_id ); 387 393 while ( $parent_project_id ) { 388 $editors = $editors +(array) $wpdb->get_col( $wpdb->prepare( "394 $editors['inherited'] = array_merge( $editors['inherited'], (array) $wpdb->get_col( $wpdb->prepare( " 389 395 SELECT 390 396 `user_id` … … 393 399 `project_id` = %d 394 400 AND `locale` IN (%s, 'all-locales') 395 ", $parent_project->id, $locale_slug ) ) ;401 ", $parent_project->id, $locale_slug ) ) ); 396 402 397 403 $parent_project = GP::$project->get( $parent_project_id ); … … 399 405 } 400 406 } 407 408 // Get the translation editors for all projects. 409 $editors['inherited'] = array_merge( $editors['inherited'], (array) $wpdb->get_col( $wpdb->prepare( " 410 SELECT 411 `user_id` 412 FROM {$wpdb->wporg_translation_editors} 413 WHERE 414 `project_id` = '0' 415 AND `locale` = %s 416 ", $locale_slug ) ) ); 401 417 402 418 return $editors; … … 414 430 global $wpdb; 415 431 416 $locale_contributors = array( 417 'editors' => array(), 418 'contributors' => array(), 419 ); 432 $locale_contributors = [ 433 'editors' => [ 434 'project' => [], 435 'inherited' => [], 436 ], 437 'contributors' => [], 438 ]; 420 439 421 440 // Get the translation editors of the project. 422 441 $editors = $this->get_translation_editors( $project, $locale_slug ); 423 442 443 $editor_ids = []; 444 424 445 // Get the names of the translation editors. 425 foreach ( $editors as $editor_id ) { 426 $user = get_user_by( 'id', $editor_id ); 427 if ( ! $user ) { 428 continue; 429 } 430 431 $locale_contributors['editors'][ $editor_id ] = (object) array( 432 'nicename' => $user->user_nicename, 433 'display_name' => $this->_encode( $user->display_name ), 434 'email' => $user->user_email, 435 ); 436 } 446 foreach ( [ 'project', 'inherited'] as $editor_source ) { 447 foreach ( $editors[ $editor_source ] as $editor_id ) { 448 $user = get_user_by( 'id', $editor_id ); 449 if ( ! $user ) { 450 continue; 451 } 452 453 $locale_contributors['editors'][ $editor_source ][ $editor_id ] = (object) array( 454 'nicename' => $user->user_nicename, 455 'display_name' => $this->_encode( $user->display_name ), 456 'email' => $user->user_email, 457 ); 458 459 $editor_ids[] = $editor_id; 460 } 461 462 uasort( $locale_contributors['editors'][ $editor_source ], function( $a, $b ) { 463 return strcasecmp( $a->display_name, $b->display_name ); 464 } ); 465 } 466 437 467 unset( $editors ); 438 468 … … 469 499 ); 470 500 } 471 472 $editors = array_keys( $locale_contributors['editors'] );473 501 474 502 // Get the names of the contributors. … … 502 530 'waiting_count' => $contributor->waiting_count, 503 531 'fuzzy_count' => $contributor->fuzzy_count, 504 'is_editor' => in_array( $user->ID, $editor s ),532 'is_editor' => in_array( $user->ID, $editor_ids ), 505 533 ); 506 534 } 507 unset( $contributors, $editor s );535 unset( $contributors, $editor_ids ); 508 536 509 537 uasort( $locale_contributors['contributors'], function( $a, $b ) { 510 538 return $a->total_count < $b->total_count; 511 } );512 513 uasort( $locale_contributors['editors'], function( $a, $b ) {514 return strcasecmp( $a->display_name, $b->display_name );515 539 } ); 516 540
Note: See TracChangeset
for help on using the changeset viewer.