Changeset 9848 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
- Timestamp:
- 05/12/2020 04:56:02 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
r9802 r9848 121 121 add_filter( 'bbp_edit_topic_pre_content', array( $this, 'support_slack_trac_code_trick' ), 19 ); 122 122 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 123 127 } 124 128 … … 1178 1182 return $content; 1179 1183 } 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 } 1180 1215 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)