Changeset 6923 for trunk/src/includes/replies/template.php
- Timestamp:
- 11/09/2019 05:35:42 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/replies/template.php
r6922 r6923 436 436 437 437 // Set needed variables 438 $reply_id = bbp_get_reply_id ( $reply_id ); 439 $topic_id = bbp_get_reply_topic_id( $reply_id ); 438 $reply_id = bbp_get_reply_id( $reply_id ); 439 440 // Juggle reply & topic IDs for unpretty URL formatting 441 if ( bbp_is_reply( $reply_id ) ) { 442 $topic_id = bbp_get_reply_topic_id( $reply_id ); 443 } elseif ( bbp_is_topic( $reply_id ) ) { 444 $topic_id = bbp_get_topic_id( $reply_id ); 445 $reply_id = $topic_id; 446 } 440 447 441 448 // Hierarchical reply page … … 448 455 } 449 456 457 // Get links & URLS 450 458 $reply_hash = '#post-' . $reply_id; 451 459 $topic_link = bbp_get_topic_permalink( $topic_id, $redirect_to ); 452 460 $topic_url = remove_query_arg( 'view', $topic_link ); 453 461 462 // Get vars needed to support pending topics with unpretty links 463 $has_slug = bbp_get_topic( $topic_id )->post_name; 464 $pretty = bbp_use_pretty_urls(); 465 $published = ! bbp_is_topic_pending( $topic_id ); 466 454 467 // Don't include pagination if on first page 455 468 if ( 1 >= $reply_page ) { 456 $url = user_trailingslashit( $topic_url ) . $reply_hash; 469 470 // Pretty permalinks 471 if ( ! empty( $has_slug ) && ! empty( $pretty ) && ! empty( $published ) ) { 472 $url = user_trailingslashit( $topic_url ) . $reply_hash; 473 474 // Unpretty links 475 } else { 476 $url = $topic_url . $reply_hash; 477 } 457 478 458 479 // Include pagination … … 460 481 461 482 // Pretty permalinks 462 if ( bbp_use_pretty_urls() ) {483 if ( ! empty( $has_slug ) && ! empty( $pretty ) && ! empty( $published ) ) { 463 484 $url = trailingslashit( $topic_url ) . trailingslashit( bbp_get_paged_slug() ) . $reply_page; 464 485 $url = user_trailingslashit( $url ) . $reply_hash; 465 486 466 // Yucky links487 // Unpretty links 467 488 } else { 468 489 $url = add_query_arg( 'paged', $reply_page, $topic_url ) . $reply_hash; … … 762 783 $reply_id = bbp_get_reply_id( $reply_id ); 763 784 $revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true ); 764 $revision_log = empty( $revision_log ) ? array() : $revision_log; 785 $revision_log = ! empty( $revision_log ) 786 ? $revision_log 787 : array(); 765 788 766 789 // Filter & return … … 852 875 * 853 876 * @since 2.0.0 bbPress (r3496) 877 * @since 2.6.0 bbPress (r6922) Returns false if topic is also not published 854 878 * 855 879 * @param int $reply_id Optional. Topic id … … 858 882 function bbp_is_reply_published( $reply_id = 0 ) { 859 883 $reply_id = bbp_get_reply_id( $reply_id ); 884 $topic_id = bbp_get_reply_topic_id( $reply_id ); 860 885 $status = bbp_get_public_status_id(); 861 $reply_status = bbp_get_reply_status( $reply_id ) === $status; 886 $topic_status = bbp_is_topic_published( $topic_id ); 887 $reply_status = ( bbp_get_reply_status( $reply_id ) === $status ); 888 $retval = ( $reply_status && $topic_status ); 862 889 863 890 // Filter & return 864 return (bool) apply_filters( 'bbp_is_reply_published', (bool) $re ply_status, $reply_id );891 return (bool) apply_filters( 'bbp_is_reply_published', (bool) $retval, $reply_id ); 865 892 } 866 893 … … 1396 1423 function bbp_get_reply_topic_id( $reply_id = 0 ) { 1397 1424 $reply_id = bbp_get_reply_id( $reply_id ); 1398 $topic_id = get_post_field( 'post_parent', $reply_id );1425 $topic_id = (int) get_post_field( 'post_parent', $reply_id ); 1399 1426 1400 1427 // Meta-data fallback 1401 1428 if ( empty( $topic_id ) ) { 1402 $topic_id = get_post_meta( $reply_id, '_bbp_topic_id', true );1429 $topic_id = (int) get_post_meta( $reply_id, '_bbp_topic_id', true ); 1403 1430 } 1404 1431 1405 1432 // Filter 1406 1433 if ( ! empty( $topic_id ) ) { 1407 $topic_id = bbp_get_topic_id( $topic_id );1408 } 1409 1410 // Filter & return 1411 return (int) apply_filters( 'bbp_get_reply_topic_id', (int)$topic_id, $reply_id );1434 $topic_id = (int) bbp_get_topic_id( $topic_id ); 1435 } 1436 1437 // Filter & return 1438 return (int) apply_filters( 'bbp_get_reply_topic_id', $topic_id, $reply_id ); 1412 1439 } 1413 1440 … … 1433 1460 function bbp_get_reply_forum_id( $reply_id = 0 ) { 1434 1461 $reply_id = bbp_get_reply_id( $reply_id ); 1435 $forum_id = get_post_field( 'post_parent', bbp_get_reply_topic_id( $reply_id ) ); 1462 $topic_id = bbp_get_reply_topic_id( $reply_id ); 1463 $forum_id = (int) get_post_field( 'post_parent', $topic_id ); 1436 1464 1437 1465 // Meta-data fallback 1438 1466 if ( empty( $forum_id ) ) { 1439 $forum_id = get_post_meta( $reply_id, '_bbp_forum_id', true );1467 $forum_id = (int) get_post_meta( $reply_id, '_bbp_forum_id', true ); 1440 1468 } 1441 1469 1442 1470 // Filter 1443 1471 if ( ! empty( $forum_id ) ) { 1444 $forum_id = bbp_get_forum_id( $forum_id );1472 $forum_id = (int) bbp_get_forum_id( $forum_id ); 1445 1473 } 1446 1474 … … 2272 2300 2273 2301 // If pretty permalinks are enabled, make our pagination pretty 2274 if ( bbp_use_pretty_urls() ) {2302 if ( bbp_use_pretty_urls() && ! bbp_is_topic_pending( $topic_id )) { 2275 2303 2276 2304 // User's replies
Note: See TracChangeset
for help on using the changeset viewer.