Changeset 5636 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php
- Timestamp:
- 07/09/2017 03:29:48 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php
r5635 r5636 101 101 102 102 /** 103 * Add query vars for user's "Reviews Written", "Active Topics", 104 * and "Topics Replied To" pages. 103 * Add query vars for user's "Reviews Written" and "Topics Replied To" views. 105 104 * 106 105 * @param array $query_vars Query vars. … … 109 108 public function add_query_vars( $query_vars ) { 110 109 $query_vars[] = 'wporg_single_user_reviews'; 111 $query_vars[] = 'wporg_single_user_active_topics';112 110 $query_vars[] = 'wporg_single_user_topics_replied_to'; 113 111 return $query_vars; … … 115 113 116 114 /** 117 * Add rewrite rules for user's "Reviews Written", "Active Topics", 118 * and "Topics Replied To" pages. 115 * Add rewrite rules for user's "Reviews Written" and "Topics Replied To" views. 119 116 */ 120 117 public function add_rewrite_rules() { … … 122 119 123 120 $user_reviews_rule = bbp_get_user_slug() . '/([^/]+)/reviews/'; 124 $user_active_topics_rule = bbp_get_user_slug() . '/([^/]+)/active/';125 121 $user_topics_replied_to_rule = bbp_get_user_slug() . '/([^/]+)/replied-to/'; 126 122 … … 141 137 add_rewrite_rule( $user_reviews_rule . $feed_rule, 'index.php?' . $user_id . '=$matches[1]&wporg_single_user_reviews=1&' . $feed_id . '=$matches[2]', $priority ); 142 138 143 // Add user's "Active Topics" page rewrite rules.144 add_rewrite_rule( $user_active_topics_rule . $base_rule, 'index.php?' . $user_id . '=$matches[1]&wporg_single_user_active_topics=1', $priority );145 add_rewrite_rule( $user_active_topics_rule . $paged_rule, 'index.php?' . $user_id . '=$matches[1]&wporg_single_user_active_topics=1&' . $paged_id . '=$matches[2]', $priority );146 add_rewrite_rule( $user_active_topics_rule . $feed_rule, 'index.php?' . $user_id . '=$matches[1]&wporg_single_user_active_topics=1&' . $feed_id . '=$matches[2]', $priority );147 148 139 // Add user's "Topics Replied To" page rewrite rules. 149 140 add_rewrite_rule( $user_topics_replied_to_rule . $base_rule, 'index.php?' . $user_id . '=$matches[1]&wporg_single_user_topics_replied_to=1', $priority ); … … 153 144 154 145 /** 155 * Set WP_Query::bbp_is_single_user_profile to false on user's "Reviews Written" ,156 * "Active Topics", and "Topics Replied To" pages.146 * Set WP_Query::bbp_is_single_user_profile to false on user's "Reviews Written" 147 * and "Topics Replied To" views. 157 148 * 158 149 * @param WP_Query $query Current query object. … … 162 153 get_query_var( 'wporg_single_user_reviews' ) 163 154 || 164 get_query_var( 'wporg_single_user_active_topics' )165 ||166 155 get_query_var( 'wporg_single_user_topics_replied_to' ) 167 156 ) { … … 189 178 190 179 /** 191 * Set the arguments for user's "Reviews Written" and "Active Topics" queries.180 * Set the arguments for user's "Reviews Written" query. 192 181 * 193 182 * @param array $args WP_Query arguments. … … 195 184 */ 196 185 public function parse_user_topics_query_args( $args ) { 197 // Forums onhttps://wordpress.org/support/.186 // Forums at https://wordpress.org/support/. 198 187 if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) && WPORG_SUPPORT_FORUMS_BLOGID == get_current_blog_id() ) { 199 200 188 // Set forum ID for topic and review queries. 201 189 if ( get_query_var( 'wporg_single_user_reviews' ) ) { 202 190 $args['post_parent'] = Plugin::REVIEWS_FORUM_ID; 203 } elseif ( bbp_is_single_user_topics() || get_query_var( 'wporg_single_user_active_topics' )) {191 } elseif ( bbp_is_single_user_topics() ) { 204 192 $args['post_parent__not_in'] = array( Plugin::REVIEWS_FORUM_ID ); 205 193 } 206 207 // Rosetta forums.208 } else {209 210 // Only look at the last year of topics for user's "Active Topics" view.211 // For the main forums, the same is done in Performance_Optimizations::has_topics().212 if ( get_query_var( 'wporg_single_user_active_topics' ) ) {213 $args['date_query'] = array( array(214 'after' => '1 year ago',215 ) );216 }217 194 } 218 195 … … 221 198 222 199 /** 223 * Set 'base' argument for pagination links on user's "Reviews Written" ,224 * "Active Topics", and "Topics Replied To" pages.200 * Set 'base' argument for pagination links on user's "Reviews Written" 201 * and "Topics Replied To" views. 225 202 * 226 203 * @param array $args Pagination arguments. … … 233 210 } 234 211 235 if ( get_query_var( 'wporg_single_user_active_topics' ) ) {236 $args['base'] = bbp_get_user_profile_url( bbp_get_displayed_user_id() ) . 'active/';237 $args['base'] .= bbp_get_paged_slug() . '/%#%/';238 }239 240 212 if ( get_query_var( 'wporg_single_user_topics_replied_to' ) ) { 241 213 $args['base'] = bbp_get_user_profile_url( bbp_get_displayed_user_id() ) . 'replied-to/'; … … 247 219 248 220 /** 249 * Set title for user's "Reviews Written", "Active Topics", 250 * and "Topics Replied To" pages. 221 * Set title for user's "Reviews Written" and "Topics Replied To" views. 251 222 * 252 223 * @param array $title Title parts. … … 264 235 } 265 236 266 if ( get_query_var( 'wporg_single_user_active_topics' ) ) {267 if ( bbp_is_user_home() ) {268 $title['text'] = __( 'Your Active Topics', 'wporg-forums' );269 } else {270 $title['text'] = get_userdata( bbp_get_user_id() )->display_name;271 /* translators: user's display name */272 $title['format'] = __( "%s's Active Topics", 'wporg-forums' );273 }274 }275 276 237 if ( get_query_var( 'wporg_single_user_topics_replied_to' ) ) { 277 238 if ( bbp_is_user_home() ) {
Note: See TracChangeset
for help on using the changeset viewer.