Changeset 5344 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php
- Timestamp:
- 04/15/2017 10:14:58 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php
r4441 r5344 202 202 $statuses[ $language_pack_status ]++; 203 203 204 $forums_url = $team_url = ''; 205 if ( $subdomain ) { 206 $result = get_sites( array( 207 'domain' => $subdomain . '.wordpress.org', 208 'path__in' => array( '/support/', '/forums/' ), 209 'number' => 1, 210 ) ); 211 $site = array_shift( $result ); 212 if ( $site ) { 213 $forums_url = get_home_url( $site->id, '/' ); 214 } 215 216 $result = get_sites( array( 217 'domain' => $subdomain . '.wordpress.org', 218 'path__in' => array( '/team/' ), 219 'number' => 1, 220 ) ); 221 $site = array_shift( $result ); 222 if ( $site ) { 223 $team_url = get_home_url( $site->id, '/' ); 224 } 225 } 204 $sites = get_sites( [ 205 'locale' => $locale->wp_locale, 206 'network_id' => WPORG_GLOBAL_NETWORK_ID, 207 'orderby' => 'path_length', 208 'number' => '', 209 ] ); 226 210 227 211 $locale_data[ $locale->wp_locale ] = array( … … 229 213 'translation_status' => $translation_status, 230 214 'language_pack_status' => $language_pack_status, 231 ' rosetta_site_url' => $subdomain ? 'https://' . $subdomain . '.wordpress.org' : false,232 ' forums_url' => $forums_url ? $forums_url : false,233 ' team_url' => $team_url ? $team_url : false,215 'sites' => $sites, 216 'subdomain' => $subdomain, 217 'rosetta_site_url' => "https://$subdomain.wordpress.org/", 234 218 'latest_release' => $latest_release ? $latest_release : false, 235 219 ); … … 272 256 $latest_release = $locale_data['latest_release']; 273 257 if ( $latest_release ) { 274 $locale_data['localized_core_url'] = sprintf( ' %s/wordpress-%s-%s.zip', $locale_data['rosetta_site_url'], $latest_release, $locale->wp_locale );258 $locale_data['localized_core_url'] = sprintf( 'https://%s.wordpress.org/wordpress-%s-%s.zip', $locale_data['subdomain'], $latest_release, $locale->wp_locale ); 275 259 $language_packs_data = $this->get_language_packs_data(); 276 260 … … 294 278 295 279 $contributors = $this->get_contributors( $locale ); 280 $locale_data['locale_managers'] = $contributors['locale_managers']; 296 281 $locale_data['validators'] = $contributors['validators']; 297 282 $locale_data['project_validators'] = $contributors['project_validators']; … … 313 298 } 314 299 315 $contributors = array(); 300 $contributors = []; 301 $contributors['locale_managers'] = $this->get_locale_managers( $locale ); 316 302 $contributors['validators'] = $this->get_general_translation_editors( $locale ); 317 303 $contributors['project_validators'] = $this->get_project_translation_editors( $locale ); … … 355 341 356 342 /** 357 * Get the general translation editors for the given locale.343 * Get the locale managers for the given locale. 358 344 * 359 345 * @param GP_Locale $locale 360 346 * @return array 361 347 */ 362 private function get_general_translation_editors( $locale ) { 363 global $wpdb; 364 365 $editors = array(); 366 367 $users = $wpdb->get_col( $wpdb->prepare( " 368 SELECT `user_id` FROM `translate_translation_editors` 369 WHERE `project_id` = '0' AND `locale` = %s 370 ", $locale->slug ) ); 371 372 if ( ! $users ) { 373 return $editors; 374 } 375 376 $user_data = $wpdb->get_results( "SELECT ID, user_nicename, display_name, user_email FROM $wpdb->users WHERE ID IN (" . implode( ',', $users ) . ")" ); 377 foreach ( $user_data as $user ) { 378 if ( $user->display_name && $user->display_name !== $user->user_nicename ) { 379 $editors[ $user->user_nicename ] = array( 380 'display_name' => $user->display_name, 381 'email' => $user->user_email, 382 'nice_name' => $user->user_nicename, 383 'slack' => self::get_slack_username( $user->ID ), 384 ); 385 } else { 386 $editors[ $user->user_nicename ] = array( 387 'display_name' => $user->user_nicename, 388 'email' => $user->user_email, 389 'nice_name' => $user->user_nicename, 390 'slack' => self::get_slack_username( $user->ID ), 391 ); 392 } 393 } 394 395 uasort( $editors, array( $this, '_sort_display_name_callback' ) ); 396 397 return $editors; 348 private function get_locale_managers( $locale ) { 349 $locale_managers = []; 350 351 $result = get_sites( [ 352 'locale' => $locale->wp_locale, 353 'network_id' => WPORG_GLOBAL_NETWORK_ID, 354 'path' => '/', 355 'fields' => 'ids', 356 'number' => '1', 357 ] ); 358 $site_id = array_shift( $result ); 359 if ( ! $site_id ) { 360 return $locale_managers; 361 } 362 363 $users = get_users( [ 364 'blog_id' => $site_id, 365 'role' => 'locale_manager', 366 'count_total' => false, 367 ] ); 368 369 foreach ( $users as $user ) { 370 $locale_managers[ $user->user_nicename ] = $this->prepare_user( $user ); 371 } 372 373 uasort( $locale_managers, [ $this, '_sort_display_name_callback' ] ); 374 375 return $locale_managers; 398 376 } 399 377 … … 404 382 * @return array 405 383 */ 384 private function get_general_translation_editors( $locale ) { 385 $editors = []; 386 387 $result = get_sites( [ 388 'locale' => $locale->wp_locale, 389 'network_id' => WPORG_GLOBAL_NETWORK_ID, 390 'path' => '/', 391 'fields' => 'ids', 392 'number' => '1', 393 ] ); 394 $site_id = array_shift( $result ); 395 if ( ! $site_id ) { 396 return $editors; 397 } 398 399 $users = get_users( [ 400 'blog_id' => $site_id, 401 'role' => 'general_translation_editor', 402 'count_total' => false, 403 ] ); 404 405 foreach ( $users as $user ) { 406 $editors[ $user->user_nicename ] = $this->prepare_user( $user ); 407 } 408 409 uasort( $editors, [ $this, '_sort_display_name_callback' ] ); 410 411 return $editors; 412 } 413 414 /** 415 * Get the general translation editors for the given locale. 416 * 417 * @param GP_Locale $locale 418 * @return array 419 */ 406 420 private function get_project_translation_editors( $locale ) { 407 global $wpdb; 408 409 $editors = array(); 410 411 $users = $wpdb->get_col( $wpdb->prepare( " 412 SELECT `user_id` FROM `translate_translation_editors` 413 WHERE `project_id` <> '0' AND `locale` = %s 414 ", $locale->slug ) ); 415 416 if ( ! $users ) { 421 $editors = []; 422 423 $result = get_sites( [ 424 'locale' => $locale->wp_locale, 425 'network_id' => WPORG_GLOBAL_NETWORK_ID, 426 'path' => '/', 427 'fields' => 'ids', 428 'number' => '1', 429 ] ); 430 $site_id = array_shift( $result ); 431 if ( ! $site_id ) { 417 432 return $editors; 418 433 } 419 434 420 $user_data = $wpdb->get_results( "SELECT ID, user_nicename, display_name, user_email FROM $wpdb->users WHERE ID IN (" . implode( ',', $users ) . ")" ); 421 foreach ( $user_data as $user ) { 422 if ( $user->display_name && $user->display_name !== $user->user_nicename ) { 423 $editors[ $user->user_nicename ] = array( 424 'display_name' => $user->display_name, 425 'email' => $user->user_email, 426 'nice_name' => $user->user_nicename, 427 'slack' => self::get_slack_username( $user->ID ), 428 ); 429 } else { 430 $editors[ $user->user_nicename ] = array( 431 'display_name' => $user->user_nicename, 432 'email' => $user->user_email, 433 'nice_name' => $user->user_nicename, 434 'slack' => self::get_slack_username( $user->ID ), 435 ); 436 } 437 } 438 439 uasort( $editors, array( $this, '_sort_display_name_callback' ) ); 435 $users = get_users( [ 436 'blog_id' => $site_id, 437 'role' => 'translation_editor', 438 'count_total' => false, 439 ] ); 440 441 foreach ( $users as $user ) { 442 $editors[ $user->user_nicename ] = $this->prepare_user( $user ); 443 } 444 445 uasort( $editors, [ $this, '_sort_display_name_callback' ] ); 440 446 441 447 return $editors; 448 } 449 450 /** 451 * Prepares user objects for output. 452 * 453 * @param \WP_User $user The user. 454 * @return array List of user data. 455 */ 456 private function prepare_user( $user ) { 457 if ( $user->display_name && $user->display_name !== $user->user_nicename ) { 458 return [ 459 'display_name' => $user->display_name, 460 'email' => $user->user_email, 461 'nice_name' => $user->user_nicename, 462 'slack' => self::get_slack_username( $user->ID ), 463 ]; 464 } else { 465 return [ 466 'display_name' => $user->user_nicename, 467 'email' => $user->user_email, 468 'nice_name' => $user->user_nicename, 469 'slack' => self::get_slack_username( $user->ID ), 470 ]; 471 } 442 472 } 443 473
Note: See TracChangeset
for help on using the changeset viewer.