Making WordPress.org

Ticket #2668: 2668.2.patch

File 2668.2.patch, 4.3 KB (added by SergeyBiryukov, 8 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php

     
    3939
    4040                add_action( 'wp_ajax_replyto-comment', array( $this, 'save_custom_comment' ), 0 );
    4141                add_filter( 'comment_row_actions', array( $this, 'custom_comment_row_actions' ), 10, 2 );
     42                add_filter( 'get_comment_link', array( $this, 'link_internal_notes_to_admin' ), 10, 2 );
    4243
    4344                // Admin Metaboxes
    4445                add_action( 'add_meta_boxes', array( $this, 'register_admin_metaboxes' ), 10, 2 );
     
    108109                        switch ( $hook_suffix ) {
    109110                                case 'post.php':
    110111                                        wp_enqueue_style( 'plugin-admin-post-css', plugins_url( 'css/edit-form.css', Plugin_Directory\PLUGIN_FILE ), array( 'edit' ), 4 );
    111                                         wp_enqueue_script( 'plugin-admin-post-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( 'wp-util', 'wp-lists' ), 1 );
     112                                        wp_enqueue_script( 'plugin-admin-post-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( 'wp-util', 'wp-lists' ), 2 );
    112113                                        wp_localize_script( 'plugin-admin-post-js', 'pluginDirectory', array(
    113114                                                'removeCommitterAYS' => __( 'Are you sure you want to remove this committer?', 'wporg-plugins' ),
    114115                                        ) );
     
    413414        }
    414415
    415416        /**
     417         * Changes the permalink for internal notes to link to the edit post screen.
     418         *
     419         * @param string $link         The comment permalink with '#comment-$id' appended.
     420         * @param \WP_Comment $comment The current comment object.
     421         * @return string The permalink to the given comment.
     422         */
     423        public function link_internal_notes_to_admin( $link, $comment ) {
     424                if ( 'internal-note' === $comment->comment_type ) {
     425                        $link = get_edit_post_link( $comment->comment_post_ID );
     426                        $link = $link . '#comment-' . $comment->comment_ID;
     427                }
     428
     429                return $link;
     430        }
     431
     432        /**
    416433         * Saves a comment that is not built-in.
    417434         *
    418435         * We pretty much have to replicate all of `wp_ajax_replyto_comment()` to be able to comment on draft posts.
     
    494511                        }
    495512                }
    496513
     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;
     519                        }
     520                }
     521
    497522                $comment_id = wp_new_comment( $comment_data );
    498523                $comment    = get_comment( $comment_id );
    499524                if ( ! $comment ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js

     
    2222                        _.each( $( '#post-body' ).find( '.comments-box' ), PluginEdit.loadComments );
    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 );
    2728
     
    107108
    108109                        window.commentReply && commentReply.addcomment( $( '#post_ID' ).val() );
    109110
    110                         // Add a field with the custom comment type.
    111                         $( '#replyrow' ).find( '.comment-reply' ).append( $( '<input/>' ).attr({
    112                                 type: 'hidden',
    113                                 name: 'comment_type',
    114                                 value: $( '.comments-box' ).data( 'comment-type' )
    115                         }) );
     111                        PluginEdit.addCommentTypeField( event );
    116112                },
    117113
     114                addCommentTypeField: function( event ) {
     115                        if ( 0 === $( '#replyrow' ).find( '.comment-reply input[name="comment_type"]' ).length ) {
     116                                // Add a field with the custom comment type.
     117                                $( '#replyrow' ).find( '.comment-reply' ).append( $( '<input/>' ).attr({
     118                                        type: 'hidden',
     119                                        name: 'comment_type',
     120                                        value: $( '.comments-box' ).data( 'comment-type' )
     121                                }) );
     122                        }
     123                },
     124
    118125                toggleCommitterForm: function( event ) {
    119126                        var $form = $( '#add-committer' );
    120127