Making WordPress.org


Ignore:
Timestamp:
02/20/2023 02:50:11 PM (2 years ago)
Author:
amieiro
Message:

Translate: Sync gp-translation-helpers with GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/includes/class-gp-translation-helpers.php

    r12205 r12405  
    7575        );
    7676        gp_enqueue_style( 'gp-discussion-css' );
     77
     78        wp_register_style(  // todo: these CSS should be integrated in GlotPress.
     79            'gp-translation-helpers-editor',
     80            plugins_url( 'css/editor.css', __DIR__ ),
     81            array(),
     82            filemtime( plugin_dir_path( __DIR__ ) . 'css/editor.css' )
     83        );
     84        gp_enqueue_style( 'gp-translation-helpers-editor' );
    7785
    7886        add_filter( 'gp_translation_row_template_more_links', array( $this, 'translation_row_template_more_links' ), 10, 5 );
     
    371379     *
    372380     *  @param string $template Template of the current page.
    373      *  @param string $translation_set Current translation set
     381     *  @param array  $translation_set Current translation set.
    374382     *
    375383     * @return void
     
    396404                'nonce'           => wp_create_nonce( 'gp_comment_feedback' ),
    397405                'locale_slug'     => $translation_set['locale_slug'],
    398                 'comment_reasons' => Helper_Translation_Discussion::get_comment_reasons(),
     406                'comment_reasons' => Helper_Translation_Discussion::get_comment_reasons( $translation_set['locale_slug'] ),
     407            )
     408        );
     409
     410        wp_register_script(
     411            'gp-translation-helpers-editor',
     412            plugins_url( 'js/editor.js', __DIR__ ),
     413            array( 'gp-editor' ),
     414            filemtime( plugin_dir_path( __DIR__ ) . 'js/editor.js' ),
     415            true
     416        );
     417        gp_enqueue_scripts( array( 'gp-translation-helpers-editor' ) );
     418
     419        wp_localize_script(
     420            'gp-translation-helpers-editor',
     421            '$gp_translation_helpers_editor',
     422            array(
     423                'translation_helper_url' => gp_url_project( $translation_set['project']->path, gp_url_join( $translation_set['locale_slug'], $translation_set['translation_set']->slug, '-get-translation-helpers' ) ),
     424                'reply_text'             => esc_attr__( 'Reply' ),
     425                'cancel_reply_text'      => esc_html__( 'Cancel reply' ),
     426            )
     427        );
     428        wp_localize_script(
     429            'gp-translation-helpers-editor',
     430            'wpApiSettings',
     431            array(
     432                'root'           => esc_url_raw( rest_url() ),
     433                'nonce'          => wp_create_nonce( 'wp_rest' ),
     434                'admin_ajax_url' => admin_url( 'admin-ajax.php' ),
    399435            )
    400436        );
     
    413449        $helper_discussion    = new Helper_Translation_Discussion();
    414450        $locale_slug          = $helper_discussion->sanitize_comment_locale( sanitize_text_field( $_POST['data']['locale_slug'] ) );
    415         $translation_status   = $helper_discussion->sanitize_translation_status( sanitize_text_field( $_POST['data']['translation_status'] ) );
     451        $translation_status   = ! empty( $_POST['data']['translation_status'] ) ? array_map( array( $helper_discussion, 'sanitize_translation_status' ), $_POST['data']['translation_status'] ) : null;
    416452        $translation_id_array = ! empty( $_POST['data']['translation_id'] ) ? array_map( array( $helper_discussion, 'sanitize_translation_id' ), $_POST['data']['translation_id'] ) : null;
    417453        $original_id_array    = ! empty( $_POST['data']['original_id'] ) ? array_map( array( $helper_discussion, 'sanitize_original_id' ), $_POST['data']['original_id'] ) : null;
     
    451487            foreach ( $original_id_array as $index => $single_original_id ) {
    452488                $comment_id = $this->insert_comment( $comment, $single_original_id, $comment_reason, $translation_id_array[ $index ], $locale_slug, $_SERVER, $translation_status );
    453                 $comment    = get_comment( $comment_id );
    454                 GP_Notifications::add_related_comment( $comment );
     489                $_comment   = get_comment( $comment_id );
     490                GP_Notifications::add_related_comment( $_comment );
    455491            }
    456492        }
     
    461497        }
    462498
    463         wp_send_json_success();
     499        wp_send_json_success( 'success' );
    464500    }
    465501
Note: See TracChangeset for help on using the changeset viewer.