Ticket #2071: 2071.1.diff
| File 2071.1.diff, 5.6 KB (added by , 10 years ago) |
|---|
-
inc/class-directory-compat.php
47 47 // before subscriptions go out for `bbp_new_topic` at priority 10. 48 48 add_action( 'bbp_new_topic', array( $this, 'new_topic' ), 9, 4 ); 49 49 50 // Always check if reply needs compat meta fields 51 add_action( 'bbp_new_reply', array( $this, 'new_reply' ), 9, 7 ); 52 50 53 // Remove new topic form at the bottom of reviews forum. 51 54 add_filter( 'bbp_get_template_part', array( $this, 'noop_reviews_forum_form_topic' ), 10, 3 ); 52 55 } … … 602 605 } 603 606 604 607 /** 605 * Set the compat taxonomy on a topic if that data is provided on new post.608 * Set the compat taxonomy and meta fields on a topic if that data is provided on new post. 606 609 * 607 610 * @param int $topic_id The topic id 608 611 * @param int $forum_id The forum id … … 619 622 $object = $this->get_object( $_POST['wporg_compat_slug'] ); 620 623 621 624 if ( ! empty( $object ) ) { 625 // Set compat taxonomy term 622 626 wp_set_object_terms( $topic_id, $this->slug(), $this->taxonomy(), false ); 627 628 // Set compat meta fields 629 update_post_meta( $topic_id, '_wporg_compat', $this->compat() ); 630 update_post_meta( $topic_id, '_wporg_compat_slug', $this->slug() ); 623 631 } 624 632 } 625 633 } 626 634 627 635 /** 636 * Set the compat meta fields on a new reply if parent topic has them. 637 * 638 * @param int $reply_id The reply id 639 * @param int $topic_id The topic id 640 * @param int $forum_id The forum id 641 * @param int|array $anonymous_data 0 or anonymous author data 642 * @param int $reply_author The reply author id 643 * @param bool $deprecated 644 * @param int $reply_to The reply id of replied that is replied to. 645 */ 646 public function new_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, $deprecated, $reply_to ) { 647 // Check if parent topic has compat meta fields 648 if ( 649 $compat = get_post_meta( $topic_id, '_wporg_compat', true ) 650 && 651 $slug = get_post_meta( $topic_id, '_wporg_compat_slug', true ) 652 ) { 653 // Set compat meta fields 654 update_post_meta( $reply_id, '_wporg_compat', $compat ); 655 update_post_meta( $reply_id, '_wporg_compat_slug', $slug ); 656 } 657 } 658 659 /** 628 660 * Set up and cache the plugin or theme details. 629 661 * 630 662 * @param string $slug The object slug -
inc/class-support-compat.php
41 41 if ( isset( $query_vars['feed'] ) && isset( $query_vars['wporg_user_login'] ) ) { 42 42 if ( isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], array( 'plugin-committer' ) ) ) { 43 43 $this->query = $query_vars; 44 add_filter( 'bbp_get_view_query_args', array( $this, 'get_view_query_args_for_feed' ), 10, 2 );45 44 46 // Override bbPress topic pubDate handling to show topic time and not last active time 47 add_filter( 'get_post_metadata', array( $this, 'topic_pubdate_correction_for_feed' ), 10, 4 ); 45 // Show plugin committer name in feed title. 46 add_filter( 'bloginfo_rss', array( $this, 'get_title_for_feed' ), 10, 2 ); 47 48 // Immediately show feed. 49 $this->feed_trap(); 48 50 } 49 51 } 50 52 return $query_vars; 51 53 } 52 54 53 public function topic_pubdate_correction_for_feed( $value, $object_id, $meta_key, $single ) { 54 // We only care about _bbp_last_active_time in this particular context 55 if( $meta_key == '_bbp_last_active_time' ) { 56 $value = get_post_time( 'Y-m-d H:i:s', true, $object_id ); 57 } 58 return $value; 59 } 60 61 public function get_view_query_args_for_feed( $retval, $view ) { 55 /** 56 * Display topics and replies in compat view feed. 57 */ 58 public function feed_trap() { 62 59 switch( $this->query['bbp_view'] ) { 63 60 case 'plugin-committer' : 64 return array( 65 'post_parent__in' => array( Plugin::PLUGINS_FORUM_ID, Plugin::REVIEWS_FORUM_ID ), 66 'post_status' => 'publish', 67 'tax_query' => array( array( 68 'taxonomy' => 'topic-plugin', 69 'field' => 'slug', 70 'terms' => $this->get_plugin_slugs_by_committer( $this->query['wporg_user_login'] ), 71 ) ), 72 'show_stickies' => false, 73 'orderby' => 'ID', 61 $the_query = array( 62 'feed' => true, 63 'post_status' => array( bbp_get_public_status_id(), bbp_get_closed_status_id() ), 64 'posts_per_page' => bbp_get_replies_per_rss_page(), 65 'order' => 'DESC', 66 'meta_query' => array( 67 array( 68 'key' => '_wporg_compat', 69 'value' => 'plugin', 70 ), 71 array( 72 'key' => '_wporg_compat_slug', 73 'value' => $this->get_plugin_slugs_by_committer( $this->query['wporg_user_login'] ), 74 'compare' => 'IN', 75 ), 76 ), 74 77 ); 75 78 break; 76 79 } 77 return $retval; 80 81 // Output the feed. 82 bbp_display_replies_feed_rss2( $the_query ); 78 83 } 79 84 85 /** 86 * Display view name in its feed title. 87 * 88 * @param string $title Title of the site. 89 * @param string $type Type of $title to filter. 90 * @return string $title Filtered title if $type is 'name', default original. 91 */ 92 public function get_title_for_feed( $title, $type ) { 93 if ( 'name' == $type ) { 94 switch( $this->query['bbp_view'] ) { 95 case 'plugin-committer' : 96 $title .= ' » ' . convert_chars( sprintf( __( 'Plugin Committer » %s', 'wporg-forums' ), $this->query['wporg_user_login'] ) ); 97 break; 98 } 99 } 100 101 return $title; 102 } 103 80 104 public function parse_query() { 81 105 $user_login = get_query_var( 'wporg_user_login' ); 82 106 $view = get_query_var( 'bbp_view' );