Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/26/2017 09:50:36 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Forms: Introduce bbp_tab_index_attribute() helpers to handle tabindex attribute output.

Note that these functions are used but normally their output is suppressed, because overriding the browser's natural tabindex order is impolite, and may introduce more issues than it actually fixes.

(Also includes some surrounding code clean-up.)

File:
1 edited

Legend:

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

    r6415 r6433  
    17061706
    17071707        // Get the reply to use it's ID and post_parent
    1708         $reply = bbp_get_reply( $r['id'] );
     1708        $reply    = bbp_get_reply( $r['id'] );
     1709        $topic_id = bbp_get_reply_topic_id( $reply->ID );
    17091710
    17101711        // Bail if no reply or user cannot reply
    1711         if ( empty( $reply ) || ! bbp_current_user_can_access_create_reply_form() ) {
     1712        if ( empty( $reply ) || empty( $topic_id ) || bbp_is_single_reply() || ! bbp_current_user_can_access_create_reply_form() ) {
    17121713            return;
    17131714        }
     
    17401741        // Add $uri to the array, to be passed through the filter
    17411742        $r['uri'] = $uri;
    1742         $retval   = $r['link_before'] . '<a role="button" href="' . esc_url( $r['uri'] ) . '" class="bbp-reply-to-link"' . $onclick . '>' . esc_html( $r['reply_text'] ) . '</a>' . $r['link_after'];
     1743        $retval   = $r['link_before'] . '<a role="button" href="' . esc_url( $r['uri'] ) . '" class="bbp-reply-to-link"' . $onclick . '>' . $r['reply_text'] . '</a>' . $r['link_after'];
    17431744
    17441745        return apply_filters( 'bbp_get_reply_to_link', $retval, $r, $args );
     
    17741775        // Set default text
    17751776        if ( empty( $text ) ) {
    1776             $text = __( 'Cancel', 'bbpress' );
     1777            $text = esc_html__( 'Cancel', 'bbpress' );
    17771778        }
    17781779
     
    19971998        ), 'get_reply_edit_link' );
    19981999
     2000        // Get reply
    19992001        $reply = bbp_get_reply( $r['id'] );
    20002002
     
    20482050    function bbp_get_reply_edit_url( $reply_id = 0 ) {
    20492051
     2052        // Bail if no reply
    20502053        $reply = bbp_get_reply( $reply_id );
    20512054        if ( empty( $reply ) ) {
     
    21272130        ), 'get_reply_trash_link' );
    21282131
     2132        // Get reply
    21292133        $reply = bbp_get_reply( $r['id'] );
    21302134
     2135        // Bail if no reply or current user cannot delete
    21312136        if ( empty( $reply ) || ! current_user_can( 'delete_reply', $reply->ID ) ) {
    21322137            return;
    21332138        }
    21342139
    2135         $actions = array();
    2136 
     2140        $actions    = array();
     2141        $trash_days = bbp_get_trash_days( bbp_get_reply_post_type() );
     2142
     2143        // Trashed
    21372144        if ( bbp_is_reply_trash( $reply->ID ) ) {
    21382145            $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'untrash', 'reply_id' => $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-restore-link">' . $r['restore_text'] . '</a>';
    2139         } elseif ( EMPTY_TRASH_DAYS ) {
     2146
     2147        // Trash
     2148        } elseif ( ! empty( $trash_days ) ) {
    21402149            $actions['trash']   = '<a title="' . esc_attr__( 'Move this item to the Trash',      'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'trash',   'reply_id' => $reply->ID ) ), 'trash-'   . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-trash-link">'   . $r['trash_text']   . '</a>';
    21412150        }
    21422151
    2143         if ( bbp_is_reply_trash( $reply->ID ) || !EMPTY_TRASH_DAYS ) {
     2152        // No trash
     2153        if ( bbp_is_reply_trash( $reply->ID ) || empty( $trash_days ) ) {
    21442154            $actions['delete']  = '<a title="' . esc_attr__( 'Delete this item permanently',     'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'delete',  'reply_id' => $reply->ID ) ), 'delete-'  . $reply->post_type . '_' . $reply->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-reply-delete-link">' . $r['delete_text'] . '</a>';
    21452155        }
     
    21982208        ), 'get_reply_spam_link' );
    21992209
     2210        // Get reply
    22002211        $reply = bbp_get_reply( $r['id'] );
    22012212
     2213        // Bail if no reply or current user cannot moderate
    22022214        if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {
    22032215            return;
     
    22632275        ), 'get_reply_move_link' );
    22642276
     2277        // Get IDs
    22652278        $reply_id = bbp_get_reply_id( $r['id'] );
    22662279        $topic_id = bbp_get_reply_topic_id( $reply_id );
    22672280
     2281        // Bail if no reply ID or user cannot moderate
    22682282        if ( empty( $reply_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
    22692283            return;
     
    23312345        ), 'get_topic_split_link' );
    23322346
     2347        // Get IDs
    23332348        $reply_id = bbp_get_reply_id( $r['id'] );
    23342349        $topic_id = bbp_get_reply_topic_id( $reply_id );
    23352350
    2336         if ( empty( $reply_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
     2351        // Bail if no reply/topic ID, or user cannot moderate
     2352        if ( empty( $reply_id ) || empty( $topic_id ) || ! current_user_can( 'moderate', $topic_id ) ) {
    23372353            return;
    23382354        }
     
    23952411        ), 'get_reply_approve_link' );
    23962412
     2413        // Get reply
    23972414        $reply = bbp_get_reply( $r['id'] );
    23982415
     2416        // Bail if no reply or current user cannot moderate
    23992417        if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {
    24002418            return;
     
    28562874        }
    28572875
    2858         // Used variables
    2859         $tab = ! empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : '';
    2860 
    28612876        // Start an output buffer, we'll finish it after the select loop
    28622877        ob_start(); ?>
    28632878
    2864         <select name="<?php echo esc_attr( $r['select_id'] ) ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php echo $tab; ?>>
     2879        <select name="<?php echo esc_attr( $r['select_id'] ) ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>>
    28652880
    28662881            <?php foreach ( bbp_get_reply_statuses( $r['reply_id'] ) as $key => $label ) : ?>
Note: See TracChangeset for help on using the changeset viewer.