Making WordPress.org

Changeset 4929


Ignore:
Timestamp:
02/18/2017 09:57:45 PM (10 years ago)
Author:
ocean90
Message:

Translate/Rosetta: Add infrastructure for Cross-Locale PTEs.

Props akirk.
See #2000.

Location:
sites/trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/js/rosetta-roles.js

    r2650 r4929  
    255255                        $( '#project-loading' ).remove();
    256256
     257                        // Mark the first item as active.
     258                        var $firstActive = view.$el.find( 'li.active' );
     259                        if ( ! $firstActive.length ) {
     260                                $firstActive = view.$el.find( 'li input[type=radio]' );
     261                        }
     262                        if ( ! $firstActive.length ) {
     263                                $firstActive = view.$el.find( 'li:first-child' );
     264                        }
     265                        $firstActive.closest( 'li' ).addClass( 'active' );
     266
    257267                        this.views.ready();
    258268
  • sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php

    r4347 r4929  
    1212}
    1313
     14require __DIR__ . '/cross-locale-pte.php';
     15
    1416class Rosetta_Roles {
    1517        /**
    … …  
    6870                $this->gp_locale = $gp_locale;
    6971
    70                 add_action( 'admin_menu', array( $this, 'register_translation_editors_page' ) );
    71                 add_filter( 'set-screen-option', array( $this, 'save_custom_screen_options' ), 10, 3 );
    72 
    73                 add_action( 'translation_editor_added', array( $this, 'update_wporg_profile_badge' ) );
    74                 add_action( 'translation_editor_removed', array( $this, 'update_wporg_profile_badge' ) );
     72                if ( ! is_main_site() ) {
     73                        add_action( 'admin_menu', array( $this, 'register_translation_editors_page' ) );
     74                        add_filter( 'set-screen-option', array( $this, 'save_custom_screen_options' ), 10, 3 );
     75
     76                        add_action( 'translation_editor_added', array( $this, 'update_wporg_profile_badge' ) );
     77                        add_action( 'translation_editor_removed', array( $this, 'update_wporg_profile_badge' ) );
     78                }
    7579
    7680                add_action( 'wp_ajax_rosetta-get-projects', array( $this, 'ajax_rosetta_get_projects' ) );
     81
     82                Cross_Locale_PTE::init_admin();
    7783        }
    7884
    … …  
    9399                add_action( 'load-' . $this->translation_editors_page, array( $this, 'load_translation_editors_page' ) );
    94100                add_action( 'load-' . $this->translation_editors_page, array( $this, 'register_screen_options' ) );
    95                 add_action( 'admin_print_scripts-' . $this->translation_editors_page, array( $this, 'enqueue_scripts' ) );
    96                 add_action( 'admin_footer-' . $this->translation_editors_page, array( $this, 'print_js_templates' ) );
    97                 add_action( 'admin_print_styles-' . $this->translation_editors_page, array( $this, 'enqueue_styles' ) );
     101                add_action( 'admin_print_scripts-' . $this->translation_editors_page, array( __CLASS__, 'enqueue_scripts' ) );
     102                add_action( 'admin_footer-' . $this->translation_editors_page, array( __CLASS__, 'print_js_templates' ) );
     103                add_action( 'admin_print_styles-' . $this->translation_editors_page, array( __CLASS__, 'enqueue_styles' ) );
    98104        }
    99105
    … …  
    101107         * Enqueues scripts.
    102108         */
    103         public function enqueue_scripts() {
     109        public static function enqueue_scripts() {
    104110                wp_enqueue_script( 'string_score', plugins_url( '/js/string_score.min.js', __FILE__ ), array(), '0.1.22', true );
    105                 wp_enqueue_script( 'rosetta-roles', plugins_url( '/js/rosetta-roles.js', __FILE__ ), array( 'jquery', 'wp-backbone', 'string_score' ), '9', true );
     111                wp_enqueue_script( 'rosetta-roles', plugins_url( '/js/rosetta-roles.js', __FILE__ ), array( 'jquery', 'wp-backbone', 'string_score' ), '10', true );
    106112        }
    107113
    … …  
    109115         * Enqueues styles.
    110116         */
    111         public function enqueue_styles() {
     117        public static function enqueue_styles() {
    112118                $suffix = is_rtl() ? '-rtl' : '';
    113119                wp_enqueue_style( 'rosetta-roles', plugins_url( "/css/rosetta-roles$suffix.css", __FILE__ ), array(), '4' );
    … …  
    117123         * Prints JavaScript templates.
    118124         */
    119         public function print_js_templates() {
     125        public static function print_js_templates() {
    120126                ?>
    121127                <script id="tmpl-project-checkbox" type="text/html">
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-rosetta-roles/inc/class-plugin.php

    r4510 r4929  
    55use GP;
    66use GP_Locales;
     7use Cross_Locale_PTE;
     8
     9require_once WPMU_PLUGIN_DIR . '/rosetta-network/roles/cross-locale-pte.php';
    710
    811class Plugin {
    … …  
    6871                add_action( 'gp_project_created', array( $this, 'project_created' ) );
    6972                add_action( 'gp_project_saved', array( $this, 'project_saved' ) );
     73                add_filter( 'gp_translation_set_import_status', array( 'Cross_Locale_PTE', 'gp_translation_set_import_status' ), 9, 3 );
    7074
    7175                if ( is_admin() ) {
    … …  
    97101                if ( $this->is_global_administrator( $args['user_id'] ) ) {
    98102                        return true;
     103                }
     104
     105                // Grant permissions to Cross-Locale PTEs.
     106                $cross_locale_pte_verdict = Cross_Locale_PTE::gp_pre_can_user( $verdict, $args );
     107        #       var_dump($cross_locale_pte_verdict);
     108                if ( is_bool( $cross_locale_pte_verdict ) ) {
     109                        return $cross_locale_pte_verdict;
    99110                }
    100111
Note: See TracChangeset for help on using the changeset viewer.