WordPress.org

Making WordPress.org

Changeset 5335


Ignore:
Timestamp:
04/14/2017 09:34:12 PM (3 years ago)
Author:
coffee2code
Message:

Plugin Directory: Ensure replies to internal notes are assigned the proper comment_type when made outside of the edit plugin page.

Props SergeyBiryukov.
Fixes #2668.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php

    r5318 r5335  
    110110                case 'post.php':
    111111                    wp_enqueue_style( 'plugin-admin-post-css', plugins_url( 'css/edit-form.css', Plugin_Directory\PLUGIN_FILE ), array( 'edit' ), 4 );
    112                     wp_enqueue_script( 'plugin-admin-post-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( 'wp-util', 'wp-lists' ), 2 );
     112                    wp_enqueue_script( 'plugin-admin-post-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( 'wp-util', 'wp-lists' ), 3 );
    113113                    wp_localize_script( 'plugin-admin-post-js', 'pluginDirectory', array(
    114114                        'removeCommitterAYS' => __( 'Are you sure you want to remove this committer?', 'wporg-plugins' ),
     
    509509                    $comment_auto_approved = true;
    510510                }
     511            }
     512        }
     513
     514        // Inherit comment type from parent comment.
     515        if ( ! $comment_data['comment_type'] ) {
     516            $parent = get_comment( $comment_parent );
     517            if ( $parent && $parent->comment_post_ID == $comment_post_ID ) {
     518                $comment_data['comment_type'] = $parent->comment_type;
    511519            }
    512520        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js

    r5308 r5335  
    2323
    2424            $( '#add-new-comment' ).on( 'click', 'a.button', PluginEdit.prepareCommentForm );
     25            $( '#the-comment-list' ).on( 'click', '.reply a', PluginEdit.addCommentTypeField );
    2526
    2627            $( '#add-committer-toggle' ).on( 'click', PluginEdit.toggleCommitterForm );
     
    112113            window.commentReply && commentReply.addcomment( $( '#post_ID' ).val() );
    113114
    114             // Add a field with the custom comment type.
    115             $( '#replyrow' ).find( '.comment-reply' ).append( $( '<input/>' ).attr({
    116                 type: 'hidden',
    117                 name: 'comment_type',
    118                 value: $( '.comments-box' ).data( 'comment-type' )
    119             }) );
     115            PluginEdit.addCommentTypeField( event );
     116        },
     117
     118        addCommentTypeField: function( event ) {
     119            if ( 0 === $( '#replyrow' ).find( '.comment-reply input[name="comment_type"]' ).length ) {
     120                // Add a field with the custom comment type.
     121                $( '#replyrow' ).find( '.comment-reply' ).append( $( '<input/>' ).attr({
     122                    type: 'hidden',
     123                    name: 'comment_type',
     124                    value: $( '.comments-box' ).data( 'comment-type' )
     125                }) );
     126            }
    120127        },
    121128
Note: See TracChangeset for help on using the changeset viewer.