Skip to:
Content

bbPress.org

Changeset 7148


Ignore:
Timestamp:
11/05/2020 05:06:10 PM (6 years ago)
Author:
johnjamesjacoby
Message:

Replies: fix clicking "Reply" link from the lead topic.

This commit adjusts reply.js and bbp_get_topic_reply_link() so clicking "Reply" from the lead topic now behaves similarly to clicking "Reply" from a reply. This includes support for hierarchical replies being on or off.

In trunk, for 2.7. Fixes #3385.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/topics/template.php

    r7006 r7148  
    28522852                        'link_after'  => '',
    28532853                        'reply_text'  => esc_html_x( 'Reply', 'verb', 'bbpress' ),
     2854                        'add_below'   => 'post',
     2855                        'respond_id'  => 'new-reply-' . bbp_get_topic_id(),
    28542856                ), 'get_topic_reply_link' );
    28552857
    … …  
    28622864                }
    28632865
    2864                 // Add $uri to the array, to be passed through the filter
    2865                 $r['uri'] = '#new-post';
    2866                 $retval   = $r['link_before'] . '<a role="button" href="' . esc_url( $r['uri'] ) . '" class="bbp-topic-reply-link">' . $r['reply_text'] . '</a>' . $r['link_after'];
     2866                // Only add onclick if replies are threaded
     2867                $onclick = bbp_thread_replies()
     2868                        ? ' onclick="return addReply.cancelForm();"'
     2869                        : '';
     2870
     2871                // Add $uri to the array, to be passed through the filter
     2872                $r['uri'] = remove_query_arg( array( 'bbp_reply_to', '_wpnonce' ) ) . '#new-post';
     2873                $retval   = $r['link_before'] . '<a role="button" href="' . esc_url( $r['uri'] ) . '" class="bbp-topic-reply-link"' . $onclick . '>' . $r['reply_text'] . '</a>' . $r['link_after'];
    28672874
    28682875                // Filter & return
  • trunk/src/templates/default/js/reply.js

    r7056 r7148  
    6363                 */
    6464                cancel.onclick = function () {
    65                         var r       = addReply,
    66                                 temp    = r.getElement( 'bbp-temp-form-div' ),
    67                                 respond = r.getElement( r.respondId );
    68 
    69                         r.removeEditor();
    70 
    71                         if ( ! temp || ! respond ) {
    72                                 return;
    73                         }
    74 
    75                         r.getElement( 'bbp_reply_to' ).value = '0';
    76 
    77                         temp.parentNode.insertBefore( respond, temp );
    78                         temp.parentNode.removeChild( temp );
    79 
    80                         this.style.display = 'none';
    81                         this.onclick       = null;
    82 
    83                         r.addEditor();
     65                        t.cancelForm( this );
    8466                };
    8567
    8668                t.scrollToForm();
    8769
     70                /* Prevent click from going through */
     71                return false;
     72        },
     73
     74        /**
     75         * Cancel the reply form.
     76         *
     77         * @since 2.6.6
     78         * @returns {void}
     79         */
     80        cancelForm: function () {
     81                var r       = addReply,
     82                        temp    = r.getElement( 'bbp-temp-form-div' ),
     83                        cancel  = r.getElement( 'bbp-cancel-reply-to-link' ),
     84                        respond = r.getElement( r.respondId );
     85
     86                r.removeEditor();
     87
     88                /* Allow click to go through */
     89                if ( ! temp || ! respond ) {
     90                        return;
     91                }
     92
     93                r.getElement( 'bbp_reply_to' ).value = '0';
     94
     95                temp.parentNode.insertBefore( respond, temp );
     96                temp.parentNode.removeChild( temp );
     97
     98                cancel.style.display = 'none';
     99                cancel.onclick       = null;
     100
     101                r.addEditor();
     102                r.scrollToForm();
     103
     104                /* Prevent click from going through */
    88105                return false;
    89106        },
Note: See TracChangeset for help on using the changeset viewer.