Ticket #2174: 2174.patch
File 2174.patch, 14.6 KB (added by , 7 years ago) |
---|
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php
5 5 abstract class Directory_Compat { 6 6 7 7 abstract protected function compat(); 8 abstract protected function compat_views(); 8 9 abstract protected function compat_title(); 9 10 abstract protected function reviews_title(); 10 11 abstract protected function activity_title(); … … 109 110 if ( isset( $query_vars['feed'] ) && isset( $query_vars[ $this->query_var() ] ) ) { 110 111 111 112 // Compat views are hooked in a special order, and need help with feed queries. 112 if ( isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], array( $this->compat(), 'reviews', 'active') ) ) {113 if ( isset( $query_vars['bbp_view'] ) && in_array( $query_vars['bbp_view'], $this->compat_views() ) ) { 113 114 $this->query = $query_vars; 114 115 add_filter( 'bbp_get_view_query_args', array( $this, 'get_view_query_args_for_feed' ), 10, 2 ); 115 116 … … 172 173 $this->{$this->compat()} = $object; 173 174 174 175 switch ( $this->query['bbp_view'] ) { 175 case 'plugin': 176 case 'theme': 176 case $this->compat(): 177 177 $translation = $this->compat_title(); 178 178 break; 179 179 case 'reviews': … … 182 182 case 'active': 183 183 $translation = $this->activity_title(); 184 184 break; 185 case 'unresolved': 186 $translation = $this->unresolved_title(); 187 break; 185 188 } 186 189 187 190 return $translation; … … 230 233 'show_stickies' => false, 231 234 ); 232 235 break; 236 237 // Return unresolved topics from the support forum. 238 case 'unresolved' : 239 return array( 240 'post_parent' => $this->forum_id(), 241 'post_status' => 'publish', 242 'tax_query' => array( array( 243 'taxonomy' => $this->taxonomy(), 244 'field' => 'slug', 245 'terms' => $this->query[ $this->query_var() ], 246 ) ), 247 'meta_key' => 'topic_resolved', 248 'meta_type' => 'CHAR', 249 'meta_value' => 'no', 250 'meta_compare' => '=', 251 'show_stickies' => false, 252 'orderby' => 'ID', 253 ); 254 break; 233 255 } 234 256 return $retval; 235 257 } … … 344 366 || 345 367 ( bbp_is_single_forum() && Plugin::REVIEWS_FORUM_ID == bbp_get_forum_id() ) 346 368 || 347 ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'plugin', 'theme', 'reviews', 'active') ) )369 ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), $this->compat_views() ) ) 348 370 ) { 349 371 $terms = get_the_terms( $topic_id, $this->taxonomy() ); 350 372 if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { … … 357 379 } 358 380 359 381 public function add_rewrite_rules() { 360 $priority = 'top';382 $priority = 'top'; 361 383 362 $root_id = $this->compat(); 363 $root_var = $this->query_var(); 364 $review_id = 'reviews'; 365 $active_id = 'active'; 384 $root_id = $this->compat(); 385 $root_var = $this->query_var(); 386 $review_id = 'reviews'; 387 $active_id = 'active'; 388 $unresolved_id = 'unresolved'; 366 389 367 $support_rule = $this->compat() . '/([^/]+)/'; 368 $reviews_rule = $this->compat() . '/([^/]+)/' . $review_id . '/'; 369 $active_rule = $this->compat() . '/([^/]+)/' . $active_id . '/'; 390 $support_rule = $this->compat() . '/([^/]+)/'; 391 $reviews_rule = $this->compat() . '/([^/]+)/' . $review_id . '/'; 392 $active_rule = $this->compat() . '/([^/]+)/' . $active_id . '/'; 393 $unresolved_rule = $this->compat() . '/([^/]+)/' . $unresolved_id . '/'; 370 394 371 395 $feed_id = 'feed'; 372 396 $view_id = bbp_get_view_rewrite_id(); … … 393 417 add_rewrite_rule( $active_rule . $base_rule, 'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]', $priority ); 394 418 add_rewrite_rule( $active_rule . $paged_rule, 'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority ); 395 419 add_rewrite_rule( $active_rule . $feed_rule, 'index.php?' . $view_id . '=' . $active_id . '&' . $root_var . '=$matches[1]&' . $feed_id . '=$matches[2]', $priority ); 420 421 // Add unresolved view rewrite rules. 422 add_rewrite_rule( $unresolved_rule . $base_rule, 'index.php?' . $view_id . '=' . $unresolved_id . '&' . $root_var . '=$matches[1]', $priority ); 423 add_rewrite_rule( $unresolved_rule . $paged_rule, 'index.php?' . $view_id . '=' . $unresolved_id . '&' . $root_var . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority ); 424 add_rewrite_rule( $unresolved_rule . $feed_rule, 'index.php?' . $view_id . '=' . $unresolved_id . '&' . $root_var . '=$matches[1]&' . $feed_id . '=$matches[2]', $priority ); 396 425 } 397 426 398 427 public function add_query_var( $query_vars ) { … … 459 488 'show_stickies' => false, 460 489 ) 461 490 ); 491 492 // Add unresolved topics view. 493 bbp_register_view( 494 'unresolved', 495 $this->unresolved_title(), 496 array( 497 'post_parent' => $this->forum_id(), 498 'post_status' => 'publish', 499 'tax_query' => array( array( 500 'taxonomy' => $this->taxonomy(), 501 'field' => 'slug', 502 'terms' => $this->slug(), 503 ) ), 504 'meta_key' => 'topic_resolved', 505 'meta_type' => 'CHAR', 506 'meta_value' => 'no', 507 'meta_compare' => '=', 508 'orderby' => 'ID', 509 'show_stickies' => false, 510 ) 511 ); 462 512 } 463 513 464 514 /** … … 468 518 global $wp_rewrite; 469 519 470 520 $view = bbp_get_view_id( $view ); 471 if ( ! in_array( $view, array( 'active', 'reviews', $this->compat()) ) ) {521 if ( ! in_array( $view, $this->compat_views() ) ) { 472 522 return $url; 473 523 } 474 524 … … 475 525 // Pretty permalinks. 476 526 if ( $wp_rewrite->using_permalinks() ) { 477 527 switch ( $view ) { 528 case 'reviews' : 478 529 case 'active' : 479 case ' reviews' :530 case 'unresolved' : 480 531 $url = $wp_rewrite->root . $this->compat() . '/' . $this->slug() . '/' . $view; 481 532 break; 482 533 … … 506 557 } 507 558 508 559 $view = bbp_get_view_id(); 509 if ( ! in_array( $view, array( $this->compat(), 'reviews', 'active') ) ) {560 if ( ! in_array( $view, $this->compat_views() ) ) { 510 561 return $r; 511 562 } 512 563 … … 521 572 522 573 $r[1] = sprintf( $compat_breadcrumb, esc_html( $this->title() ) ); 523 574 524 if ( in_array( $view, array( 'reviews', 'active' ) ) ) {575 if ( in_array( $view, array( 'reviews', 'active', 'unresolved' ) ) ) { 525 576 $r[1] = sprintf( $compat_breadcrumb, sprintf( 526 577 '<a href="%s" class="bbp-breadcrumb-forum">%s</a>', 527 578 esc_url( bbp_get_view_url( $this->compat() ) ), … … 529 580 ) ); 530 581 if ( 'reviews' == $view ) { 531 582 $r[2] = __( 'Reviews', 'wporg-forums' ); 583 } elseif ( 'active' == $view ) { 584 $r[2] = __( 'Active Topics', 'wporg-forums' ); 532 585 } else { 533 $r[2] = __( ' ActiveTopics', 'wporg-forums' );586 $r[2] = __( 'Unresolved Topics', 'wporg-forums' ); 534 587 } 535 588 } 536 589 return $r; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php
214 214 $this->query = $r; 215 215 } 216 216 217 if ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'plugin', 'theme', 'reviews', 'active' ) ) ) {217 if ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'plugin', 'theme', 'reviews', 'active', 'unresolved' ) ) ) { 218 218 $r['post_parent__not_in'] = array( Plugin::THEMES_FORUM_ID, Plugin::PLUGINS_FORUM_ID, Plugin::REVIEWS_FORUM_ID ); 219 219 } 220 220 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php
13 13 return self::COMPAT; 14 14 } 15 15 16 function compat_views() { 17 return array( self::COMPAT, 'reviews', 'active', 'unresolved' ); 18 } 19 16 20 function compat_title() { 17 21 /* translators: %s: plugin title */ 18 22 return sprintf( _x( '[%s] Support', 'plugin', 'wporg-forums' ), $this->title() ); … … 28 32 return sprintf( _x( '[%s] Recent Activity', 'plugin', 'wporg-forums' ), $this->title() ); 29 33 } 30 34 35 function unresolved_title() { 36 /* translators: %s: plugin title */ 37 return sprintf( _x( '[%s] Unresolved Topics', 'plugin', 'wporg-forums' ), $this->title() ); 38 } 39 31 40 function slug() { 32 41 return $this->slug; 33 42 } … … 83 92 include_once WPORGPATH . 'extend/plugins-plugins/_plugin-icons.php'; 84 93 } 85 94 86 $plugin = sprintf( '<a href="//wordpress.org/plugins/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->plugin->post_title ) ); 87 $faq = sprintf( '<a href="//wordpress.org/plugins/%s/faq/">%s</a>', esc_attr( $this->slug() ), __( 'Frequently Asked Questions', 'wporg-forums' ) ); 88 $support = sprintf( '<a href="//wordpress.org/support/plugin/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) ); 89 $active = sprintf( '<a href="//wordpress.org/support/plugin/%s/active">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) ); 90 $reviews = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) ); 91 $create = ''; 95 $plugin = sprintf( '<a href="//wordpress.org/plugins/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->plugin->post_title ) ); 96 $faq = sprintf( '<a href="//wordpress.org/plugins/%s/faq/">%s</a>', esc_attr( $this->slug() ), __( 'Frequently Asked Questions', 'wporg-forums' ) ); 97 $support = sprintf( '<a href="//wordpress.org/support/plugin/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) ); 98 $active = sprintf( '<a href="//wordpress.org/support/plugin/%s/active/">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) ); 99 $unresolved = sprintf( '<a href="//wordpress.org/support/plugin/%s/unresolved/">%s</a>', esc_attr( $this->slug() ), __( 'Unresolved Topics', 'wporg-forums' ) ); 100 $reviews = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) ); 101 $create = ''; 92 102 93 103 $create_label = ''; 94 104 if ( isset( $this->ratings ) && $this->ratings->is_rating_view() && bbp_current_user_can_access_create_topic_form() ) { … … 115 125 <?php endif; ?> 116 126 <li><?php echo $support; ?></li> 117 127 <li><?php echo $active; ?></li> 128 <li><?php echo $unresolved; ?></li> 118 129 <li><?php echo $reviews; ?></li> 119 130 <?php if ( $create ) : ?> 120 131 <li class="create-topic"><?php echo $create; ?></li> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php
13 13 return self::COMPAT; 14 14 } 15 15 16 function compat_views() { 17 return array( self::COMPAT, 'reviews', 'active', 'unresolved' ); 18 } 19 16 20 function compat_title() { 17 21 /* translators: %s: theme title */ 18 22 return sprintf( _x( '[%s] Support', 'theme', 'wporg-forums' ), $this->title() ); … … 28 32 return sprintf( _x( '[%s] Recent Activity', 'theme', 'wporg-forums' ), $this->title() ); 29 33 } 30 34 35 function unresolved_title() { 36 /* translators: %s: theme title */ 37 return sprintf( _x( '[%s] Unresolved Topics', 'theme', 'wporg-forums' ), $this->title() ); 38 } 39 31 40 function slug() { 32 41 return $this->slug; 33 42 } … … 79 88 } 80 89 81 90 public function do_topic_sidebar() { 82 $theme = sprintf( '<a href="//wordpress.org/themes/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->theme->post_title ) ); 83 $support = sprintf( '<a href="//wordpress.org/support/theme/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) ); 84 $active = sprintf( '<a href="//wordpress.org/support/theme/%s/active">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) ); 85 $reviews = sprintf( '<a href="//wordpress.org/support/theme/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) ); 86 $create = ''; 91 $theme = sprintf( '<a href="//wordpress.org/themes/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->theme->post_title ) ); 92 $support = sprintf( '<a href="//wordpress.org/support/theme/%s/">%s</a>', esc_attr( $this->slug() ), __( 'Support Threads', 'wporg-forums' ) ); 93 $active = sprintf( '<a href="//wordpress.org/support/theme/%s/active/">%s</a>', esc_attr( $this->slug() ), __( 'Active Topics', 'wporg-forums' ) ); 94 $unresolved = sprintf( '<a href="//wordpress.org/support/theme/%s/unresolved/">%s</a>', esc_attr( $this->slug() ), __( 'Unresolved Topics', 'wporg-forums' ) ); 95 $reviews = sprintf( '<a href="//wordpress.org/support/theme/%s/reviews/">%s</a>', esc_attr( $this->slug() ), __( 'Reviews', 'wporg-forums' ) ); 96 $create = ''; 87 97 88 98 $create_label = ''; 89 99 if ( isset( $this->ratings ) && $this->ratings->is_rating_view() && bbp_current_user_can_access_create_topic_form() ) { … … 103 113 <li><?php echo $theme; ?></li> 104 114 <li><?php echo $support; ?></li> 105 115 <li><?php echo $active; ?></li> 116 <li><?php echo $unresolved; ?></li> 106 117 <li><?php echo $reviews; ?></li> 107 118 <?php if ( $create ) : ?> 108 119 <li class="create-topic"><?php echo $create; ?></li> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php
232 232 * @return array Array of compat views. 233 233 */ 234 234 function wporg_support_get_compat_views() { 235 return array( 'theme', 'plugin', 'reviews', 'active' );235 return array( 'theme', 'plugin', 'reviews', 'active', 'unresolved' ); 236 236 } 237 237 238 238 /**