Making WordPress.org

Changeset 9848


Ignore:
Timestamp:
05/12/2020 04:56:02 AM (5 years ago)
Author:
dd32
Message:

Support Forums: Use the actual date as the title text for date links.

Fixes #5121.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r9802 r9848  
    121121        add_filter( 'bbp_edit_topic_pre_content', array( $this, 'support_slack_trac_code_trick' ),  19 );
    122122        add_filter( 'bbp_edit_forum_pre_content', array( $this, 'support_slack_trac_code_trick' ),  19 );
     123
     124        // Freshness links should have the datetime as a title rather than the thread title.
     125        add_filter( 'bbp_get_topic_freshness_link', array( $this, 'bbp_get_topic_freshness_link' ), 10, 5 );
     126
    123127    }
    124128
     
    11781182        return $content;
    11791183    }
     1184   
     1185    /**
     1186     * Alter the bbPress topic freshness links to use the date in the title attribute rather than thread title.
     1187     */
     1188    function bbp_get_topic_freshness_link( $anchor, $topic_id, $time_since, $link_url, $title ) {
     1189
     1190        // Copy-paste from bbp_get_topic_last_active_time() which only returns humanized times.
     1191        // Try to get the most accurate freshness time possible
     1192        $last_active = get_post_meta( $topic_id, '_bbp_last_active_time', true );
     1193        if ( empty( $last_active ) ) {
     1194            if ( ! empty( $reply_id ) ) {
     1195                $last_active = get_post_field( 'post_date', $reply_id );
     1196            } else {
     1197                $last_active = get_post_field( 'post_date', $topic_id );
     1198            }
     1199        }
     1200
     1201        // This is for translating the date components.
     1202        $datetime = date_create_immutable_from_format( 'Y-m-d H:i:s', $last_active );
     1203        $date     = wp_date( get_option( 'date_format' ), $datetime->getTimestamp() );
     1204        $time     = wp_date( get_option( 'time_format' ), $datetime->getTimestamp() );
     1205
     1206        return str_replace(
     1207            'title="' . esc_attr( $title ) . '"',
     1208            'title="' . esc_attr(
     1209                // bbPress string from bbp_get_reply_post_date()
     1210                sprintf( _x( '%1$s at %2$s', 'date at time', 'wporg-support' ), $date, $time )
     1211            ) . '"',
     1212            $anchor
     1213        );
     1214    }
    11801215}
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/bbpress/content-single-topic-lead.php

    r8334 r9848  
    5959                <?php endif; ?>
    6060
    61                 <p class="bbp-topic-post-date"><a href="<?php bbp_topic_permalink(); ?>" title="#<?php bbp_topic_id(); ?>" class="bbp-topic-permalink"><?php bbp_topic_post_date( bbp_get_topic_id(), true ); ?></a></p>
     61                <p class="bbp-topic-post-date"><a href="<?php bbp_topic_permalink(); ?>" title="<?php echo esc_attr( bbp_get_topic_post_date( bbp_get_topic_id() ) ); ?>" class="bbp-topic-permalink"><?php bbp_topic_post_date( bbp_get_topic_id(), true ); ?></a></p>
    6262
    6363                <?php if ( current_user_can( 'moderate', bbp_get_topic_id() ) ) : ?>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/bbpress/loop-single-reply.php

    r7818 r9848  
    4646        <div class="bbp-reply-meta">
    4747
    48         <p class="bbp-reply-post-date"><a href="<?php bbp_reply_url(); ?>" title="#<?php bbp_reply_id(); ?>" class="bbp-reply-permalink"><?php bbp_reply_post_date( bbp_get_reply_id(), true ); ?></a></p>
     48        <p class="bbp-reply-post-date"><a href="<?php bbp_reply_url(); ?>" title="<?php echo esc_attr( bbp_get_reply_post_date( bbp_get_reply_id() ) ); ?>" class="bbp-reply-permalink"><?php bbp_reply_post_date( bbp_get_reply_id(), true ); ?></a></p>
    4949
    5050        <?php if ( current_user_can( 'moderate', bbp_get_reply_topic_id() ) ) : ?>
Note: See TracChangeset for help on using the changeset viewer.