Changeset 9178
- Timestamp:
- 10/14/2019 07:40:48 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-support-compat.php
r8081 r9178 55 55 // Exclude certain forums from forum queries. 56 56 add_action( 'pre_get_posts', array( $this, 'exclude_hidden_forums' ), 1 ); 57 58 // Prefix the theme/plugin to the title for WordPress.org notifications. 59 add_filter( 'wporg_notifications_info', array( $this, 'wporg_notifications_info' ) ); 57 60 58 61 $this->loaded = true; … … 515 518 516 519 /** 520 * Filter notifications data to prefix the name of the Plugin/Theme to the title. 521 */ 522 public function wporg_notifications_info( $data ) { 523 // Bail if this notification isn't a forum topic/reply 524 if ( $data['type'] != 'forum_topic' && $data['type'] != 'forum_topic_reply' ) { 525 return $data; 526 } 527 528 $topic_id = $data['topic_id']; 529 $forum_id = bbp_get_topic_forum_id( $topic_id ); 530 531 if ( $forum_id === Plugin::PLUGINS_FORUM_ID ) { 532 $type = 'plugin'; 533 } elseif ( $forum_id === Plugin::THEMES_FORUM_ID ) { 534 $type = 'theme'; 535 } else { 536 // Not in a Plugin/Theme forum. 537 return $data; 538 } 539 540 $slugs = wp_get_post_terms( $topic_id, 'topic-' . $type, array( 'fields' => 'slugs' ) ); 541 $obj = $slugs ? Directory_Compat::get_object_by_slug_and_type( $slugs[0], $type ) : false; 542 543 if ( ! $obj ) { 544 return $data; 545 } 546 547 // Prefix the Plugin/Theme to the notification title. 548 $data['title'] = sprintf( 549 '[%s] %s', 550 $obj->post_title, 551 $data['title'] 552 ); 553 554 return $data; 555 } 556 557 /** 517 558 * In bbPress 1, topics could be referenced using their topic id, and many 518 559 * are indexed/linked via this rather than their pretty permalink. The
Note: See TracChangeset
for help on using the changeset viewer.