Changeset 6686
- Timestamp:
- 02/18/2018 02:58:36 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php
r6685 r6686 73 73 add_action( 'admin_menu', array( $this, 'register_translation_editors_page' ) ); 74 74 add_filter( 'set-screen-option', array( $this, 'save_custom_screen_options' ), 10, 3 ); 75 add_action( 'after_setup_theme', array( $this, 'register_resources_nav_menu' ) ); 75 76 76 77 add_action( 'translation_editor_added', array( $this, 'update_wporg_profile_badge' ) ); 77 78 add_action( 'translation_editor_removed', array( $this, 'update_wporg_profile_badge' ) ); 79 80 add_action( 'translation_editor_added', array( $this, 'send_email_notification' ), 10, 2 ); 81 add_action( 'translation_editor_updated', array( $this, 'send_email_notification' ), 10, 2 ); 78 82 } 79 83 … … 81 85 82 86 Cross_Locale_PTE::init_admin(); 87 } 88 89 /** 90 * Registers a nav menu for storing resources for translation editors. 91 */ 92 public function register_resources_nav_menu() { 93 register_nav_menu( 'rosetta_translation_editor_resources', __( 'Resources for translation editors', 'rosetta' ) ); 83 94 } 84 95 … … 506 517 507 518 /** 519 * Sends an email to the new translation editor. 520 * 521 * @param \WP_User $user The user object of the translation editor. 522 * @param array $projects_added List of project IDs. 523 */ 524 public function send_email_notification( $user, $projects_added ) { 525 // Don't send an email if no new projects have been added. 526 if ( ! $projects_added ) { 527 return; 528 } 529 530 $to = $user->user_email; 531 $subject = __( 'You have been added to a WordPress project as a translation editor', 'rosetta' ); 532 533 if ( [ '0' ] === $projects_added ) { 534 // General Translation Editor. 535 536 /* translators: Do not translate the placeholders USERNAME, LOCALENAME, LOCALEURL. */ 537 $message = __( 538 'Howdy ###USERNAME###, 539 540 We are happy to inform you that you have been successfully added as a General Translation Editor of WordPress for ###LOCALENAME###. 541 542 As a General Translation Editor you have access to submit and approve translations for all projects available at ###LOCALEURL###. 543 544 Alongside WordPress itself, it’s good to prioritize translating the projects that ship with it first – The default themes like Twenty Seventeen or Twenty Sixteen, and Akismet. 545 546 Please get to know how the team works by reading the Translators Handbook – https://make.wordpress.org/polyglots/handbook/, a good place to start is the General Expectations page. 547 548 As a General Translation Editor for the locale, we request that you fill out your WordPress.org profile (https://profiles.wordpress.org/profile/), register on Slack and provide a way for translation contributors to reach you. 549 550 We also ask all WordPress General Translation Editors to subscribe for notifications for their locales, you can find the notification subscription settings in your profile settings (https://profiles.wordpress.org/profile/notifications/). 551 552 The Polyglots team connects on Slack once per week at 11am UTC every Wednesday. We’d love to have you there if you can make it. Register from http://chat.wordpress.org. 553 If you have any questions about the processes or need any help, reach the team on Slack or on https://make.wordpress.org/polyglots/. 554 555 Welcome to the WordPress Polyglots team and happy translating!' 556 ); 557 558 $message = str_replace( 559 [ 560 '###USERNAME###', 561 '###LOCALENAME###', 562 '###LOCALEURL###', 563 ], 564 [ 565 $user->user_login, 566 '#' . $this->gp_locale->wp_locale . ' (' . $this->gp_locale->native_name . ')', 567 'https://translate.wordpress.org/locale/' . $this->gp_locale->slug, 568 ], 569 $message 570 ); 571 } else { 572 // Project Translation Editor. 573 574 /* translators: Do not translate the placeholders USERNAME, LOCALENAME, PROJECTLIST, RESOURCESLIST. */ 575 $message = __( 576 'Howdy ###USERNAME###, 577 578 We are happy to inform you that you have been successfully added as a Project Translation Editor for ###LOCALENAME### for the following projects: 579 580 ###PROJECTLIST### 581 582 You have been added to these projects either by your own request, or by the request of the plugin author. 583 584 Before translating, please get to know how the team works by reading the Translators Handbook – https://make.wordpress.org/polyglots/handbook/, a good place to start is the General Expectations page. 585 586 Your local translation team can be found on https://make.wordpress.org/polyglots/teams/. Make sure you get familiar with the documentation about translating in your language that other contributors from your team have prepared. 587 588 ###RESOURCESLIST### 589 590 The Polyglots team connects on Slack once per week at 11am UTC every Wednesday. We’d love to have you there if you can make it. Register from https://chat.wordpress.org/. 591 If you have any questions about the processes or need any help, reach the team on Slack or on https://make.wordpress.org/polyglots/. 592 593 Welcome to the WordPress Polyglots team and happy translating.' 594 ); 595 596 $projects = $this->get_translate_projects(); 597 $project_tree = $this->get_project_tree( $projects, 0, 1 ); 598 599 $project_list = []; 600 601 foreach ( $projects_added as $project_id ) { 602 if ( $projects[ $project_id ] ) { 603 $parent = $this->get_parent_project( $project_tree, $project_id ); 604 if ( $parent->id != $project_id ) { 605 $name = sprintf( 606 /* translators: 1: Parent project name, 2: Child project name */ 607 __( '%1$s → %2$s', 'rosetta' ), 608 $parent->name, 609 $projects[ $project_id ]->name 610 ); 611 } else { 612 $name = $projects[ $project_id ]->name; 613 } 614 615 $name = sprintf( 616 '%s: %s', 617 $name, 618 esc_url( 'https://translate.wordpress.org/projects/' . $projects[ $project_id ]->path ) 619 ); 620 621 $project_list[] = html_entity_decode( $name, ENT_QUOTES, get_bloginfo( 'charset' ) ); 622 } 623 } 624 625 $resources_list = ''; 626 627 if ( has_nav_menu( 'rosetta_translation_editor_resources' ) ) { 628 $resources_list = (string) wp_nav_menu( [ 629 'fallback_cb' => '__return_false', 630 'theme_location' => 'rosetta_translation_editor_resources', 631 'container' => false, 632 'echo' => false, 633 'depth' => 1, 634 'items_wrap' => '%3$s', 635 // Custom walker that returns plain text links. 636 'walker' => new class() extends Walker_Nav_Menu { 637 public function start_lvl( &$output, $depth = 0, $args = array() ) { 638 $output .= "\n"; 639 } 640 public function end_lvl( &$output, $depth = 0, $args = array() ) { 641 $output .= "\n"; 642 } 643 public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { 644 $href = ! empty( $item->url ) ? $item->url : ''; 645 $title = apply_filters( 'the_title', $item->title, $item->ID ); 646 $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); 647 648 $item_output = $title; 649 if ( $href ) { 650 $item_output .= ': ' . esc_url( $href ); 651 } 652 653 $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); 654 } 655 public function end_el( &$output, $item, $depth = 0, $args = array() ) { 656 $output .= "\n"; 657 } 658 }, 659 ] ); 660 } 661 662 $message = str_replace( 663 [ 664 '###USERNAME###', 665 '###LOCALENAME###', 666 '###PROJECTLIST###', 667 '###RESOURCESLIST###', 668 ], 669 [ 670 $user->user_login, 671 '#' . $this->gp_locale->wp_locale . ' (' . $this->gp_locale->native_name . ')', 672 implode( "\n", $project_list ), 673 $resources_list, 674 ], 675 $message 676 ); 677 } 678 679 $headers = "From: \"WordPress Polyglots\" <donotreply@wordpress.org>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n"; 680 681 wp_mail( $to, $subject, $message, $headers ); 682 } 683 684 /** 508 685 * Retrieves the assigned projects of a user 509 686 *
Note: See TracChangeset
for help on using the changeset viewer.