Changeset 7360
- Timestamp:
- 11/16/2025 10:43:01 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 51 edited
-
.gitignore (modified) (1 diff)
-
phpcs.xml.dist (modified) (4 diffs)
-
src/bbpress.php (modified) (4 diffs)
-
src/includes/admin/classes/class-bbp-admin.php (modified) (5 diffs)
-
src/includes/admin/classes/class-bbp-converter.php (modified) (18 diffs)
-
src/includes/admin/converters/Kunena1.php (modified) (2 diffs)
-
src/includes/admin/converters/Kunena2.php (modified) (2 diffs)
-
src/includes/admin/converters/phpBB.php (modified) (1 diff)
-
src/includes/admin/forums.php (modified) (4 diffs)
-
src/includes/admin/metaboxes.php (modified) (6 diffs)
-
src/includes/admin/replies.php (modified) (9 diffs)
-
src/includes/admin/settings.php (modified) (15 diffs)
-
src/includes/admin/tools/common.php (modified) (4 diffs)
-
src/includes/admin/tools/repair.php (modified) (26 diffs)
-
src/includes/admin/tools/reset.php (modified) (9 diffs)
-
src/includes/admin/tools/upgrade.php (modified) (17 diffs)
-
src/includes/admin/topics.php (modified) (19 diffs)
-
src/includes/common/classes.php (modified) (1 diff)
-
src/includes/common/formatting.php (modified) (1 diff)
-
src/includes/common/functions.php (modified) (16 diffs)
-
src/includes/common/template.php (modified) (88 diffs)
-
src/includes/common/widgets.php (modified) (3 diffs)
-
src/includes/core/theme-compat.php (modified) (1 diff)
-
src/includes/extend/akismet.php (modified) (3 diffs)
-
src/includes/extend/buddypress/activity.php (modified) (2 diffs)
-
src/includes/extend/buddypress/functions.php (modified) (1 diff)
-
src/includes/extend/buddypress/groups.php (modified) (3 diffs)
-
src/includes/extend/buddypress/notifications.php (modified) (1 diff)
-
src/includes/forums/functions.php (modified) (2 diffs)
-
src/includes/forums/template.php (modified) (92 diffs)
-
src/includes/replies/functions.php (modified) (3 diffs)
-
src/includes/replies/template.php (modified) (87 diffs)
-
src/includes/search/template.php (modified) (2 diffs)
-
src/includes/topics/functions.php (modified) (8 diffs)
-
src/includes/topics/template.php (modified) (11 diffs)
-
src/includes/users/functions.php (modified) (2 diffs)
-
src/includes/users/template.php (modified) (2 diffs)
-
src/templates/default/bbpress/form-allowed-tags.php (modified) (1 diff)
-
src/templates/default/bbpress/form-forum.php (modified) (3 diffs)
-
src/templates/default/bbpress/form-reply-move.php (modified) (2 diffs)
-
src/templates/default/bbpress/form-reply.php (modified) (3 diffs)
-
src/templates/default/bbpress/form-topic-merge.php (modified) (1 diff)
-
src/templates/default/bbpress/form-topic-split.php (modified) (3 diffs)
-
src/templates/default/bbpress/form-topic-tag.php (modified) (3 diffs)
-
src/templates/default/bbpress/form-topic.php (modified) (3 diffs)
-
src/templates/default/bbpress/loop-search-forum.php (modified) (1 diff)
-
src/templates/default/bbpress/loop-single-topic.php (modified) (2 diffs)
-
src/templates/default/bbpress/user-details.php (modified) (7 diffs)
-
src/templates/default/bbpress/user-profile.php (modified) (2 diffs)
-
src/templates/default/extras/taxonomy-topic-tag-edit.php (modified) (1 diff)
-
src/templates/default/extras/taxonomy-topic-tag.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/.gitignore
r7353 r7360 15 15 /phpunit.xml 16 16 /pnpm-lock.yaml 17 .phpunit.result.cache18 17 19 18 # Output directory. -
trunk/phpcs.xml.dist
r7359 r7360 492 492 </rule> 493 493 494 <rule ref="WordPress.Arrays.ArrayIndentation.CloseBraceNotAligned">495 <exclude-pattern>/src/*</exclude-pattern>496 </rule>497 498 494 <rule ref="WordPress.Arrays.ArrayIndentation.ItemNotAligned"> 499 495 <exclude-pattern>/src/*</exclude-pattern> … … 549 545 550 546 <rule ref="WordPress.Files.FileName.InvalidClassFileName"> 551 <exclude-pattern>/src/*</exclude-pattern>547 <exclude-pattern>/src/*</exclude-pattern> 552 548 </rule> 553 549 … … 565 561 566 562 <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound"> 567 <exclude-pattern>/src/*</exclude-pattern>563 <exclude-pattern>/src/*</exclude-pattern> 568 564 </rule> 569 565 … … 680 676 </rule> 681 677 682 <rule ref="WordPress.WP.I18n.MissingTranslatorsComment">683 <exclude-pattern>/src/*</exclude-pattern>684 </rule>685 686 <rule ref="WordPress.WP.I18n.NonSingularStringLiteralText">687 <exclude-pattern>/src/*</exclude-pattern>688 </rule>689 690 <rule ref="WordPress.WP.PostsPerPage.posts_per_page_posts_per_page">691 <exclude-pattern>/src/*</exclude-pattern>692 </rule>693 694 <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.ExtraSpaceAfterOpenParenthesis">695 <exclude-pattern>/src/*</exclude-pattern>696 </rule>697 698 <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.ExtraSpaceBeforeCloseParenthesis">699 <exclude-pattern>/src/*</exclude-pattern>700 </rule>701 702 <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis">703 <exclude-pattern>/src/*</exclude-pattern>704 </rule>705 706 <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis">707 <exclude-pattern>/src/*</exclude-pattern>708 </rule>709 710 <rule ref="WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter">711 <exclude-pattern>/src/*</exclude-pattern>712 </rule>713 714 <rule ref="WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore">715 <exclude-pattern>/src/*</exclude-pattern>716 </rule>717 718 <rule ref="WordPress.WhiteSpace.OperatorSpacing.SpacingAfter">719 <exclude-pattern>/src/*</exclude-pattern>720 </rule>721 722 <rule ref="WordPress.WhiteSpace.OperatorSpacing.SpacingBefore">723 <exclude-pattern>/src/*</exclude-pattern>724 </rule>725 726 678 </ruleset> -
trunk/src/bbpress.php
r7351 r7360 599 599 apply_filters( 'bbp_register_closed_post_status', array( 600 600 'label' => _x( 'Closed', 'post', 'bbpress' ), 601 /* translators: %s: Number of closed items */ 601 602 'label_count' => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'post', 'bbpress' ), 602 603 'public' => true, … … 612 613 apply_filters( 'bbp_register_spam_post_status', array( 613 614 'label' => _x( 'Spam', 'post', 'bbpress' ), 615 /* translators: %s: Number of spammed items */ 614 616 'label_count' => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'post', 'bbpress' ), 615 617 'protected' => true, … … 626 628 apply_filters( 'bbp_register_orphan_post_status', array( 627 629 'label' => _x( 'Orphan', 'post', 'bbpress' ), 630 /* translators: %s: Number of orphaned items */ 628 631 'label_count' => _nx_noop( 'Orphan <span class="count">(%s)</span>', 'Orphans <span class="count">(%s)</span>', 'post', 'bbpress' ), 629 632 'protected' => true, … … 640 643 apply_filters( 'bbp_register_hidden_post_status', array( 641 644 'label' => _x( 'Hidden', 'post', 'bbpress' ), 645 /* translators: %s: Number of hidden items */ 642 646 'label_count' => _nx_noop( 'Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', 'post', 'bbpress' ), 643 647 'private' => true, -
trunk/src/includes/admin/classes/class-bbp-admin.php
r7357 r7360 261 261 $bbp_dashicon = '<span class="bbpress-logo-icon"></span>'; 262 262 $message = $bbp_dashicon . sprintf( 263 esc_html__( 'bbPress requires a manual database upgrade. %1$s or %1$s.', 'bbpress' ), 263 /* translators: 1: "Learn More" link, 2: "Hide For Now" link */ 264 esc_html__( 'bbPress requires a manual database upgrade. %1$s or %2$s.', 'bbpress' ), 264 265 $upgrade_link, 265 266 $dismiss_link … … 1033 1034 if ( ! empty( $topics ) ) { 1034 1035 foreach ( (array) $topics as $post ) { 1036 /* translators: 1: Topic ID, 2: Topic title */ 1035 1037 printf( esc_html__( '%1$s - %2$s', 'bbpress' ), bbp_get_topic_id( $post->ID ), bbp_get_topic_title( $post->ID ) . "\n" ); 1036 1038 } … … 1113 1115 if ( ! empty( $users_query->results ) ) { 1114 1116 foreach ( (array) $users_query->results as $user ) { 1117 /* translators: 1: User ID, 2: User nicename */ 1115 1118 printf( esc_html__( '%1$s - %2$s', 'bbpress' ), bbp_get_user_id( $user->ID ), bbp_get_user_nicename( $user->ID, array( 'force' => $user->user_nicename ) ) . "\n" ); 1116 1119 } … … 1131 1134 list( $display_version ) = explode( '-', bbp_get_version() ); ?> 1132 1135 1133 <h1 class="wp-heading-inline"><?php printf( esc_html__( 'Welcome to bbPress %s', 'bbpress' ), $display_version ); ?></h1> 1136 <h1 class="wp-heading-inline"> 1137 <?php 1138 printf( 1139 /* translators: %s: bbPress version number */ 1140 esc_html__( 'Welcome to bbPress %s', 'bbpress' ), $display_version 1141 ); 1142 ?> 1143 </h1> 1134 1144 <hr class="wp-header-end"> 1135 1145 <div class="about-text"><?php printf( esc_html__( 'bbPress is fun to use, contains no artificial colors or preservatives, and is absolutely wonderful in every environment. Your community is going to love using it.', 'bbpress' ), $display_version ); ?></div> … … 1467 1477 // Site errored out, no response? 1468 1478 if ( is_wp_error( $response ) ) { 1469 wp_die( sprintf( esc_html__( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s', 'bbpress' ), $site_url, '<em>' . $response->get_error_message() . '</em>' ) ); 1479 wp_die( 1480 sprintf( 1481 /* translators: 1: Site URL, 2: Error message */ 1482 esc_html__( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s', 'bbpress' ), 1483 $site_url, 1484 '<em>' . $response->get_error_message() . '</em>' 1485 ) 1486 ); 1470 1487 } 1471 1488 -
trunk/src/includes/admin/classes/class-bbp-converter.php
r7357 r7360 177 177 'status_stopped' => esc_html__( 'Stopped', 'bbpress' ), 178 178 'status_starting' => esc_html__( 'Starting', 'bbpress' ), 179 /* translators: %s: Current step number or name */ 179 180 'status_up_next' => esc_html__( 'Doing step %s...', 'bbpress' ), 181 /* translators: %s: Number of seconds until next action */ 180 182 'status_counting' => esc_html__( 'Next in %s seconds...', 'bbpress' ) 181 183 ) … … 515 517 } else { 516 518 $this->bump_start(); 517 $this->converter_response( sprintf( esc_html__( 'Deleting previously converted data (%1$s through %2$s)', 'bbpress' ), $this->start, $this->max ) ); 519 $this->converter_response( 520 sprintf( 521 /* translators: 1: Start number, 2: End number */ 522 esc_html__( 'Deleting previously converted data (%1$s through %2$s)', 'bbpress' ), $this->start, $this->max 523 ) 524 ); 518 525 } 519 526 … … 541 548 } else { 542 549 $this->bump_start(); 550 /* translators: 1: Start user number, 2: End user number, 3: Total number of users */ 543 551 $this->converter_response( sprintf( esc_html__( 'Converting users (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 544 552 } … … 564 572 } else { 565 573 $this->bump_start(); 574 /* translators: 1: Start password number, 2: End password number */ 566 575 $this->converter_response( sprintf( esc_html__( 'Delete default WordPress user passwords (%1$s through %2$s)', 'bbpress' ), $this->start, $this->max ) ); 567 576 } … … 586 595 } else { 587 596 $this->bump_start(); 597 /* translators: 1: Start forum number, 2: End forum number, 3: Total number of forums */ 588 598 $this->converter_response( sprintf( esc_html__( 'Converting forums (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 589 599 } … … 604 614 } else { 605 615 $this->bump_start(); 616 /* translators: 1: Start forum number, 2: End forum number, 3: Total number of forums */ 606 617 $this->converter_response( sprintf( esc_html__( 'Calculating forum hierarchy (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 607 618 } … … 622 633 } else { 623 634 $this->bump_start(); 635 /* translators: 1: Start forum subscription number, 2: End forum subscription number, 3: Total number of forum subscriptions */ 624 636 $this->converter_response( sprintf( esc_html__( 'Converting forum subscriptions (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 625 637 } … … 640 652 } else { 641 653 $this->bump_start(); 654 /* translators: 1: Start topic number, 2: End topic number, 3: Total number of topics */ 642 655 $this->converter_response( sprintf( esc_html__( 'Converting topics (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 643 656 } … … 658 671 } else { 659 672 $this->bump_start(); 673 /* translators: 1: Start anonymous topic author number, 2: End anonymous topic author number, 3: Total number of anonymous topic authors */ 660 674 $this->converter_response( sprintf( esc_html__( 'Converting anonymous topic authors (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 661 675 } … … 676 690 } else { 677 691 $this->bump_start(); 692 /* translators: 1: Start sticky topic number, 2: End sticky topic number, 3: Total number of sticky topics */ 678 693 $this->converter_response( sprintf( esc_html__( 'Calculating topic stickies (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 679 694 } … … 694 709 } else { 695 710 $this->bump_start(); 711 /* translators: 1: Start super sticky topic number, 2: End super sticky topic number, 3: Total number of super sticky topics */ 696 712 $this->converter_response( sprintf( esc_html__( 'Calculating topic super stickies (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 697 713 } … … 712 728 } else { 713 729 $this->bump_start(); 730 /* translators: 1: Start closed topic number, 2: End closed topic number, 3: Total number of closed topics */ 714 731 $this->converter_response( sprintf( esc_html__( 'Calculating closed topics (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 715 732 } … … 730 747 } else { 731 748 $this->bump_start(); 749 /* translators: 1: Start topic tag number, 2: End topic tag number, 3: Total number of topic tags */ 732 750 $this->converter_response( sprintf( esc_html__( 'Converting topic tags (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 733 751 } … … 748 766 } else { 749 767 $this->bump_start(); 768 /* translators: 1: Start topic subscription number, 2: End topic subscription number, 3: Total number of topic subscriptions */ 750 769 $this->converter_response( sprintf( esc_html__( 'Converting topic subscriptions (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 751 770 } … … 766 785 } else { 767 786 $this->bump_start(); 787 /* translators: 1: Start favorite number, 2: End favorite number, 3: Total number of favorites */ 768 788 $this->converter_response( sprintf( esc_html__( 'Converting favorites (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 769 789 } … … 784 804 } else { 785 805 $this->bump_start(); 806 /* translators: 1: Start reply number, 2: End reply number, 3: Total number of replies */ 786 807 $this->converter_response( sprintf( esc_html__( 'Converting replies (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 787 808 } … … 802 823 } else { 803 824 $this->bump_start(); 825 /* translators: 1: Start anonymous reply author number, 2: End anonymous reply author number, 3: Total number of anonymous reply authors */ 804 826 $this->converter_response( sprintf( esc_html__( 'Converting anonymous reply authors (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 805 827 } … … 820 842 } else { 821 843 $this->bump_start(); 844 /* translators: 1: Start threaded reply number, 2: End threaded reply number, 3: Total number of threaded replies */ 822 845 $this->converter_response( sprintf( esc_html__( 'Calculating threaded replies parents (%1$s through %2$s of %3$s)', 'bbpress' ), $this->start, $this->max, $this->rows_in_step ) ); 823 846 } -
trunk/src/includes/admin/converters/Kunena1.php
r7352 r7360 453 453 * as one value. Array values are auto sanitized by WordPress. 454 454 */ 455 public function callback_savepass($field, $row) { 456 $pass_array = array('hash' => $field, 'salt' => $row['salt']); 455 public function callback_savepass( $field, $row ) { 456 $pass_array = array( 457 'hash' => $field, 458 'salt' => $row['salt'] 459 ); 457 460 return $pass_array; 458 461 } … … 462 465 * to a pass the user has typed in. 463 466 */ 464 public function authenticate_pass($password, $serialized_pass) { 465 $pass_array = unserialize($serialized_pass); 466 return ( md5(md5($password) . $pass_array['salt']) == $pass_array['hash'] ); 467 public function authenticate_pass( $password, $serialized_pass ) { 468 $pass_array = unserialize( $serialized_pass ); 469 470 return ( md5( md5( $password ) . $pass_array['salt'] ) == $pass_array['hash'] ); 467 471 } 468 472 -
trunk/src/includes/admin/converters/Kunena2.php
r7352 r7360 484 484 * as one value. Array values are auto sanitized by WordPress. 485 485 */ 486 public function callback_savepass($field, $row) { 487 $pass_array = array('hash' => $field, 'salt' => $row['salt']); 486 public function callback_savepass( $field, $row ) { 487 $pass_array = array( 488 'hash' => $field, 489 'salt' => $row['salt'] 490 ); 488 491 return $pass_array; 489 492 } … … 493 496 * to a pass the user has typed in. 494 497 */ 495 public function authenticate_pass( $password, $serialized_pass) {496 $pass_array = unserialize( $serialized_pass);497 return ( md5( md5($password) . $pass_array['salt']) == $pass_array['hash'] );498 public function authenticate_pass( $password, $serialized_pass ) { 499 $pass_array = unserialize( $serialized_pass ); 500 return ( md5( md5( $password ) . $pass_array['salt'] ) == $pass_array['hash'] ); 498 501 } 499 502 /** -
trunk/src/includes/admin/converters/phpBB.php
r7357 r7360 793 793 } 794 794 795 $output = substr( $setting, 0, 12);796 $output .= $this->_hash_encode64( $hash, 16, $itoa64);795 $output = substr( $setting, 0, 12 ); 796 $output .= $this->_hash_encode64( $hash, 16, $itoa64 ); 797 797 798 798 return $output; -
trunk/src/includes/admin/forums.php
r7352 r7360 449 449 case 'opened' : 450 450 $message = ( true === $is_failure ) 451 /* translators: %1$s: Forum title */ 451 452 ? sprintf( esc_html__( 'There was a problem opening the forum "%1$s".', 'bbpress' ), $forum_title ) 453 /* translators: %1$s: Forum title */ 452 454 : sprintf( esc_html__( 'Forum "%1$s" successfully opened.', 'bbpress' ), $forum_title ); 453 455 break; … … 455 457 case 'closed' : 456 458 $message = ( true === $is_failure ) 459 /* translators: %1$s: Forum title */ 457 460 ? sprintf( esc_html__( 'There was a problem closing the forum "%1$s".', 'bbpress' ), $forum_title ) 461 /* translators: %1$s: Forum title */ 458 462 : sprintf( esc_html__( 'Forum "%1$s" successfully closed.', 'bbpress' ), $forum_title ); 459 463 break; … … 723 727 724 728 // Restored from revision 725 / / translators: %s: date and time of the revision729 /* translators: %s: date and time of the revision */ 726 730 5 => isset( $_GET['revision'] ) 731 /* translators: %s: Date and time of the revision */ 727 732 ? sprintf( esc_html__( 'Forum restored to revision from %s', 'bbpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) 728 733 : false, … … 751 756 '%1$s <a target="_blank" href="%2$s">%3$s</a>', 752 757 sprintf( 758 /* translators: %s: Publish box date format, see http://php.net/date */ 753 759 esc_html__( 'Forum scheduled for: %s.', 'bbpress' ), 754 // translators: Publish box date format, see http://php.net/date755 760 '<strong>' . date_i18n( __( 'M j, Y @ G:i', 'bbpress' ), strtotime( $post_date ) ) . '</strong>' 756 761 ), -
trunk/src/includes/admin/metaboxes.php
r7357 r7360 41 41 if ( isset( $r['user_count'] ) ) { 42 42 $link = admin_url( 'users.php' ); 43 /* translators: %s: Number of users */ 43 44 $text = sprintf( _n( '%s User', '%s Users', $r['user_count_int'], 'bbpress' ), $r['user_count'] ); 44 45 $elements[] = current_user_can( 'edit_users' ) … … 50 51 if ( isset( $r['forum_count'] ) ) { 51 52 $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), admin_url( 'edit.php' ) ); 53 /* translators: %s: Number of forums */ 52 54 $text = sprintf( _n( '%s Forum', '%s Forums', $r['forum_count_int'], 'bbpress' ), $r['forum_count'] ); 53 55 $elements[] = current_user_can( 'publish_forums' ) … … 59 61 if ( isset( $r['topic_count'] ) ) { 60 62 $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); 63 /* translators: %s: Number of topics */ 61 64 $text = sprintf( _n( '%s Topic', '%s Topics', $r['topic_count_int'], 'bbpress' ), $r['topic_count'] ); 62 65 $elements[] = current_user_can( 'publish_topics' ) … … 68 71 if ( isset( $r['reply_count'] ) ) { 69 72 $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); 73 /* translators: %s: Number of replies */ 70 74 $text = sprintf( _n( '%s Reply', '%s Replies', $r['reply_count_int'], 'bbpress' ), $r['reply_count'] ); 71 75 $elements[] = current_user_can( 'publish_replies' ) … … 77 81 if ( bbp_allow_topic_tags() && isset( $r['topic_tag_count'] ) ) { 78 82 $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit-tags.php' ) ); 83 /* translators: %s: Number of topic tags */ 79 84 $text = sprintf( _n( '%s Topic Tag', '%s Topic Tags', $r['topic_tag_count_int'], 'bbpress' ), $r['topic_tag_count'] ); 80 85 $elements[] = current_user_can( 'manage_topic_tags' ) … … 283 288 284 289 <span id="wp-version-message"> 285 <?php printf( __( 'You are using <span class="b">bbPress %s</span>.', 'bbpress' ), bbp_get_version() ); ?> 290 <?php 291 printf( 292 /* translators: %s: bbPress version */ 293 __( 'You are using <span class="b">bbPress %s</span>.', 'bbpress' ), bbp_get_version() 294 ); 295 ?> 286 296 </span> 287 297 -
trunk/src/includes/admin/replies.php
r7357 r7360 249 249 */ 250 250 public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) { 251 /* translators: %s: Number of replies */ 251 252 $bulk_messages['reply']['updated'] = _n( '%s reply updated.', '%s replies updated.', $bulk_counts['updated'], 'bbpress'); 252 253 $bulk_messages['reply']['locked'] = ( 1 === $bulk_counts['locked'] ) 253 254 ? __( '1 reply not updated, somebody is editing it.', 'bbpress' ) 255 /* translators: %s: Number of replies */ 254 256 : _n( '%s reply not updated, somebody is editing it.', '%s replies not updated, somebody is editing them.', $bulk_counts['locked'], 'bbpress' ); 255 257 … … 560 562 case 'spammed' : 561 563 $message = ( true === $is_failure ) 564 /* translators: %s: Reply title */ 562 565 ? sprintf( esc_html__( 'There was a problem marking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) 566 /* translators: %s: Reply title */ 563 567 : sprintf( esc_html__( 'Reply "%1$s" successfully marked as spam.', 'bbpress' ), $reply_title ); 564 568 break; … … 566 570 case 'unspammed' : 567 571 $message = ( true === $is_failure ) 572 /* translators: %s: Reply title */ 568 573 ? sprintf( esc_html__( 'There was a problem unmarking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) 574 /* translators: %s: Reply title */ 569 575 : sprintf( esc_html__( 'Reply "%1$s" successfully unmarked as spam.', 'bbpress' ), $reply_title ); 570 576 break; … … 572 578 case 'approved' : 573 579 $message = ( true === $is_failure ) 580 /* translators: %s: Reply title */ 574 581 ? sprintf( esc_html__( 'There was a problem approving the reply "%1$s".', 'bbpress' ), $reply_title ) 582 /* translators: %s: Reply title */ 575 583 : sprintf( esc_html__( 'Reply "%1$s" successfully approved.', 'bbpress' ), $reply_title ); 576 584 break; … … 578 586 case 'unapproved' : 579 587 $message = ( true === $is_failure ) 588 /* translators: %s: Reply title */ 580 589 ? sprintf( esc_html__( 'There was a problem unapproving the reply "%1$s".', 'bbpress' ), $reply_title ) 590 /* translators: %s: Reply title */ 581 591 : sprintf( esc_html__( 'Reply "%1$s" successfully unapproved.', 'bbpress' ), $reply_title ); 582 592 break; … … 794 804 795 805 // Reply view links to topic 796 $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_reply_title( $reply->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 806 $view_title = sprintf( 807 /* translators: %s: Reply title */ 808 __( 'View “%s”', 'bbpress' ), 809 bbp_get_reply_title( $reply->ID ) 810 ); 811 812 $actions['view'] = sprintf( 813 '<a href="%1$s" title="%2$s" rel="permalink">%3$s</a>', 814 esc_url( $view_link ), 815 esc_attr( $view_title ), 816 esc_html__( 'View', 'bbpress' ) 817 ); 797 818 798 819 // User cannot view replies in trash … … 887 908 888 909 // Show the forums dropdown 889 bbp_dropdown( array( 890 'selected' => $selected, 891 'show_none' => esc_html__( 'In all forums', 'bbpress' ) 892 ) ); 910 bbp_dropdown( 911 array( 912 'selected' => $selected, 913 'show_none' => esc_html__( 'In all forums', 'bbpress' ) 914 ) 915 ); 893 916 } 894 917 … … 984 1007 985 1008 // Restored from revision 986 / / translators: %s: date and time of the revision1009 /* translators: %s: date and time of the revision */ 987 1010 5 => isset( $_GET['revision'] ) 1011 /* translators: %s: Date and time of the revision */ 988 1012 ? sprintf( esc_html__( 'Reply restored to revision from %s', 'bbpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) 989 1013 : false, … … 1012 1036 '%1$s <a target="_blank" href="%2$s">%3$s</a>', 1013 1037 sprintf( 1038 /* translators: Publish box date format, see http://php.net/date */ 1014 1039 esc_html__( 'Reply scheduled for: %s.', 'bbpress' ), 1015 // translators: Publish box date format, see http://php.net/date1016 1040 '<strong>' . date_i18n( __( 'M j, Y @ G:i', 'bbpress' ), strtotime( $post_date ) ) . '</strong>' 1017 1041 ), -
trunk/src/includes/admin/settings.php
r7357 r7360 676 676 <label for="_bbp_allow_content_edit"> 677 677 <input name="_bbp_allow_content_edit" id="_bbp_allow_content_edit" type="checkbox" value="1" <?php checked( bbp_allow_content_edit( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_content_edit' ); ?> /> 678 <?php printf( esc_html__( 'Allow users to edit their content for %s minutes after posting', 'bbpress' ), $select ); ?> 678 <?php 679 printf( 680 /* translators: %s: Total minutes to edit a post */ 681 esc_html__( 'Allow users to edit their content for %s minutes after posting', 'bbpress' ), 682 $select 683 ); 684 ?> 679 685 </label> 680 686 <p class="description"><?php esc_html_e( 'If checked, setting to "0 minutes" allows editing forever.', 'bbpress' ); ?></p> … … 701 707 <label for="_bbp_allow_content_throttle"> 702 708 <input name="_bbp_allow_content_throttle" id="_bbp_allow_content_throttle" type="checkbox" value="1" <?php checked( bbp_allow_content_throttle( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_content_throttle' ); ?> /> 703 <?php printf( esc_html__( 'Allow flood protection by throttling users for %s seconds after posting', 'bbpress' ), $select ); ?> 709 <?php 710 printf( 711 /* translators: %s: Total seconds to throttle a user */ 712 esc_html__( 'Allow flood protection by throttling users for %s seconds after posting', 'bbpress' ), 713 $select 714 ); 715 ?> 704 716 </label> 705 717 <p class="description"><?php esc_html_e( 'Use this to discourage users from spamming your forums.', 'bbpress' ); ?></p> … … 751 763 <label for="_bbp_allow_global_access"> 752 764 <input name="_bbp_allow_global_access" id="_bbp_allow_global_access" type="checkbox" value="1" <?php checked( bbp_allow_global_access( true ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_global_access' ); ?> /> 753 <?php printf( esc_html__( 'Automatically give registered visitors the %s forum role', 'bbpress' ), $select ); ?> 765 <?php 766 printf( 767 /* translators: %s: Default role name */ 768 esc_html__( 'Automatically give registered visitors the %s forum role', 'bbpress' ), 769 $select 770 ); 771 ?> 754 772 </label> 755 773 <p class="description"><?php esc_html_e( 'Uncheck this to manually assign all user access to your forums.', 'bbpress' ); ?></p> … … 902 920 903 921 <label for="_bbp_allow_threaded_replies"> 904 <input name="_bbp_allow_threaded_replies" id="_bbp_allow_threaded_replies" type="checkbox" value="1" <?php checked( '1', bbp_allow_threaded_replies( false ) ); bbp_maybe_admin_setting_disabled( '_bbp_allow_threaded_replies' ); ?> /> 905 <?php printf( esc_html__( 'Enable threaded (nested) replies %s levels deep', 'bbpress' ), $select ); ?> 922 <input name="_bbp_allow_threaded_replies" id="_bbp_allow_threaded_replies" type="checkbox" value="1" 923 <?php 924 checked( '1', bbp_allow_threaded_replies( false ) ); 925 bbp_maybe_admin_setting_disabled( '_bbp_allow_threaded_replies' ); 926 ?> 927 /> 928 <?php 929 printf( 930 /* translators: %s: Depth level input field HTML */ 931 esc_html__( 'Enable threaded (nested) replies %s levels deep', 'bbpress' ), 932 $select 933 ); 934 ?> 906 935 </label> 907 936 … … 1168 1197 if ( ! empty( $forum_archive ) ) : ?> 1169 1198 1170 <p class="description"><?php printf( esc_html__( 'This setting will be ignored because %s was found in your theme.', 'bbpress' ), '<code>' . $forum_archive . '</code>' ); ?></p> 1199 <p class="description"> 1200 <?php 1201 printf( 1202 /* translators: %s: Forum archive template file path */ 1203 esc_html__( 'This setting will be ignored because %s was found in your theme.', 'bbpress' ), 1204 '<code>' . $forum_archive . '</code>' 1205 ); 1206 ?> 1207 </p> 1171 1208 1172 1209 <?php endif; … … 1443 1480 1444 1481 // Output the dropdown for all forums 1445 $select = bbp_get_dropdown( array( 1446 'selected' => $group_root, 1447 'show_none' => esc_html__( '— No parent —', 'bbpress' ), 1448 'orderby' => 'title', 1449 'order' => 'ASC', 1450 'select_id' => '_bbp_group_forums_root_id', 1451 'disable_categories' => false, 1452 'disabled' => '_bbp_group_forums_root_id' 1453 ) ); 1482 $select = bbp_get_dropdown( 1483 array( 1484 'selected' => $group_root, 1485 'show_none' => esc_html__( '— No parent —', 'bbpress' ), 1486 'orderby' => 'title', 1487 'order' => 'ASC', 1488 'select_id' => '_bbp_group_forums_root_id', 1489 'disable_categories' => false, 1490 'disabled' => '_bbp_group_forums_root_id' 1491 ) 1492 ); 1454 1493 1455 1494 // Check cap one time … … 1468 1507 // Button & text 1469 1508 $button = '<a href="' . esc_url( $new_url ) . '">' . esc_html__( 'create a new one', 'bbpress' ) . '</a>'; 1470 $text = esc_html__( 'Use %s to contain your group forums, or %s', 'bbpress' ); //phpcs:ignore 1509 /* translators: 1: Forum select dropdown HTML, 2: Create new forum link HTML */ 1510 $text = esc_html__( 'Use %1$s to contain your group forums, or %2$s', 'bbpress' ); 1471 1511 } else { 1512 /* translators: %s: Forum select dropdown HTML */ 1472 1513 $text = esc_html__( 'Use %s to contain your group forums', 'bbpress' ); 1473 1514 } … … 1584 1625 function bbp_converter_setting_callback_dbserver() { 1585 1626 ?> 1586 1587 <input name="_bbp_converter_db_server" id="_bbp_converter_db_server" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_server', 'localhost' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_server' ); ?> /> 1588 <p class="description"><?php printf( esc_html__( 'Use default %s if same server, or IP or hostname', 'bbpress' ), '<code>localhost</code>' ); ?></p> 1589 1590 <?php 1627 <input name="_bbp_converter_db_server" 1628 id="_bbp_converter_db_server" 1629 type="text" 1630 class="code" 1631 value="<?php bbp_form_option( '_bbp_converter_db_server', 'localhost' ); ?>" 1632 <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_server' ); ?> 1633 /> 1634 <p class="description"> 1635 <?php 1636 printf( 1637 /* translators: %s: Default value wrapped in code tags */ 1638 esc_html__( 'Use default %s if same server, or IP or hostname', 'bbpress' ), 1639 '<code>localhost</code>' 1640 ); 1641 ?> 1642 </p> 1643 <?php 1591 1644 } 1592 1645 … … 1597 1650 */ 1598 1651 function bbp_converter_setting_callback_dbport() { 1599 ?> 1600 1601 <input name="_bbp_converter_db_port" id="_bbp_converter_db_port" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_port', '3306' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_port' ); ?> /> 1602 <p class="description"><?php printf( esc_html__( 'Use default %s if unsure', 'bbpress' ), '<code>3306</code>' ); ?></p> 1603 1604 <?php 1652 ?> 1653 <input name="_bbp_converter_db_port" 1654 id="_bbp_converter_db_port" 1655 type="text" 1656 class="code" 1657 value="<?php bbp_form_option( '_bbp_converter_db_port', '3306' ); ?>" 1658 <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_port' ); ?> 1659 /> 1660 <p class="description"> 1661 <?php 1662 1663 printf( 1664 /* translators: %s: Default port number wrapped in code tags */ 1665 esc_html__( 'Use default %s if unsure', 'bbpress' ), 1666 '<code>3306</code>' 1667 ); 1668 ?> 1669 </p> 1670 <?php 1605 1671 } 1606 1672 … … 1675 1741 1676 1742 <input name="_bbp_converter_db_prefix" id="_bbp_converter_db_prefix" type="text" class="code" value="<?php bbp_form_option( '_bbp_converter_db_prefix' ); ?>" <?php bbp_maybe_admin_setting_disabled( '_bbp_converter_db_prefix' ); ?> /> 1677 <p class="description"><?php printf( esc_html__( 'Use %s if converting from BuddyPress Legacy', 'bbpress' ), '<code>wp_bb_</code>' ); ?></p> 1743 <p class="description"> 1744 <?php printf( 1745 /* translators: %s: Database prefix example wrapped in code tags */ 1746 esc_html__( 'Use %s if converting from BuddyPress Legacy', 'bbpress' ), '<code>wp_bb_</code>' ); 1747 ?> 1748 </p> 1678 1749 1679 1750 <?php … … 1786 1857 // Starting or continuing? 1787 1858 $status_text = ! empty( $step ) 1859 /* translators: %s: Current step number */ 1788 1860 ? sprintf( esc_html__( 'Up next: step %s', 'bbpress' ), $step ) 1789 1861 : esc_html__( 'Ready', 'bbpress' ); … … 1796 1868 // Starting or continuing? 1797 1869 $progress_text = ! empty( $step ) 1870 /* translators: 1: Current step number, 2: Total number of steps */ 1798 1871 ? sprintf( esc_html__( 'Previously stopped at step %1$d of %2$d', 'bbpress' ), $step, $max ) 1799 1872 : esc_html__( 'Ready to go.', 'bbpress' ); ?> … … 1964 2037 echo bbp_get_form_option( $option, $default, $slug ); 1965 2038 } 1966 /** 1967 * Return settings API option 1968 * 1969 * @since 2.0.0 bbPress (r3203) 1970 * 1971 * @param string $option 1972 * @param string $default 1973 * @param bool $is_slug 1974 * 1975 * @return mixed 1976 */ 1977 function bbp_get_form_option( $option, $default = '', $is_slug = false ) { 1978 1979 // Get the option and sanitize it 1980 $value = get_option( $option, $default ); 1981 1982 // Slug? 1983 if ( true === $is_slug ) { 1984 $value = esc_attr( apply_filters( 'editable_slug', $value ) ); 1985 1986 // Not a slug 1987 } else { 1988 $value = esc_attr( $value ); 1989 } 1990 1991 // Fallback to default, unless numeric (allow zero) 1992 if ( empty( $value ) && ! is_numeric( $value ) ) { 1993 $value = $default; 1994 } 1995 1996 // Filter & return 1997 return apply_filters( 'bbp_get_form_option', $value, $option, $default, $is_slug ); 2039 2040 /** 2041 * Return settings API option 2042 * 2043 * @since 2.0.0 bbPress (r3203) 2044 * 2045 * @param string $option 2046 * @param string $default 2047 * @param bool $is_slug 2048 * 2049 * @return mixed 2050 */ 2051 function bbp_get_form_option( $option, $default = '', $is_slug = false ) { 2052 2053 // Get the option and sanitize it 2054 $value = get_option( $option, $default ); 2055 2056 // Slug? 2057 if ( true === $is_slug ) { 2058 $value = esc_attr( apply_filters( 'editable_slug', $value ) ); 2059 2060 // Not a slug 2061 } else { 2062 $value = esc_attr( $value ); 1998 2063 } 2064 2065 // Fallback to default, unless numeric (allow zero) 2066 if ( empty( $value ) && ! is_numeric( $value ) ) { 2067 $value = $default; 2068 } 2069 2070 // Filter & return 2071 return apply_filters( 'bbp_get_form_option', $value, $option, $default, $is_slug ); 2072 } 1999 2073 2000 2074 /** … … 2073 2147 foreach ( $bp->pages as $page => $page_data ) { 2074 2148 $page_base = $page . '_base'; 2149 /* translators: %s: BuddyPress page title */ 2075 2150 $page_title = sprintf( esc_html__( '%s page', 'bbpress' ), $page_data->title ); 2076 2151 $core_slugs[ $page_base ] = array( … … 2094 2169 2095 2170 // Compare 2096 if ( ( $slug !== $key ) && ( $slug_check === $this_slug ) ) : ?> 2097 2098 <span class="attention"><?php printf( esc_html__( 'Possible %1$s conflict: %2$s', 'bbpress' ), $value['context'], '<strong>' . $value['name'] . '</strong>' ); ?></span> 2099 2100 <?php endif; 2171 if ( ( $slug !== $key ) && ( $slug_check === $this_slug ) ) : 2172 ?> 2173 <span class="attention"> 2174 <?php 2175 printf( 2176 /* translators: 1: Context (e.g., "BuddyPress"), 2: Name of the conflicting item */ 2177 esc_html__( 'Possible %1$s conflict: %2$s', 'bbpress' ), 2178 $value['context'], 2179 '<strong>' . $value['name'] . '</strong>' 2180 ); 2181 ?> 2182 </span> 2183 <?php 2184 endif; 2101 2185 } 2102 2186 } -
trunk/src/includes/admin/tools/common.php
r7006 r7360 74 74 } 75 75 76 /**77 * Return the URL to run a specific repair tool78 *79 * @since 2.6.0 bbPress (r5885)80 *81 * @param string $component82 */83 function bbp_get_admin_repair_tool_run_url( $component = array() ) {84 85 // Page86 $page = ( 'repair' === $component['type'] )87 ? 'bbp-repair'88 : 'bbp-upgrade';89 90 // Arguments91 $args = array(92 'page' => $page,93 'action' => 'run',94 'checked' => array( $component['id'] )95 );96 97 // Url98 $nonced = wp_nonce_url( bbp_get_admin_repair_tool_page_url( $args ), 'bbpress-do-counts' );99 100 // Filter & return101 return apply_filters( 'bbp_get_admin_repair_tool_run_url', $nonced, $component );102 }76 /** 77 * Return the URL to run a specific repair tool 78 * 79 * @since 2.6.0 bbPress (r5885) 80 * 81 * @param string $component 82 */ 83 function bbp_get_admin_repair_tool_run_url( $component = array() ) { 84 85 // Page 86 $page = ( 'repair' === $component['type'] ) 87 ? 'bbp-repair' 88 : 'bbp-upgrade'; 89 90 // Arguments 91 $args = array( 92 'page' => $page, 93 'action' => 'run', 94 'checked' => array( $component['id'] ) 95 ); 96 97 // Url 98 $nonced = wp_nonce_url( bbp_get_admin_repair_tool_page_url( $args ), 'bbpress-do-counts' ); 99 100 // Filter & return 101 return apply_filters( 'bbp_get_admin_repair_tool_run_url', $nonced, $component ); 102 } 103 103 104 104 /** … … 253 253 */ 254 254 function bbp_admin_repair_list_search_form() { 255 ?>255 ?> 256 256 257 257 <p class="search-box"> … … 798 798 // Create the "All" link 799 799 $current = empty( $selected ) ? 'current' : ''; 800 $links[] = $r['link_before'] . '<a href="' . esc_url( $tools_url ) . '" class="' . esc_attr( $current ) . '">' . sprintf( esc_html__( 'All %s', 'bbpress' ), $r['count_before'] . count( $tools ) . $r['count_after'] ) . '</a>' . $r['link_after']; 800 801 $all_text = sprintf( 802 /* translators: %s: Number of items */ 803 esc_html__( 'All %s', 'bbpress' ), 804 $r['count_before'] . count( $tools ) . $r['count_after'] 805 ); 806 807 $links[] = sprintf( 808 '%1$s<a href="%2$s" class="%3$s">%4$s</a>%5$s', 809 $r['link_before'], 810 esc_url( $tools_url ), 811 esc_attr( $current ), 812 $all_text, 813 $r['link_after'] 814 ); 801 815 802 816 // Loop through overheads and created links … … 922 936 // Define links 923 937 $links = array( 924 $r['link_before'] . '<a href="' . esc_url( $tools_url ) . '" class="' . esc_attr( $all_current ) . '">' . sprintf( esc_html__( 'All %s', 'bbpress' ), $all_count ) . '</a>' . $r['link_after'], 925 $r['link_before'] . '<a href="' . esc_url( $filter_url ) . '" class="' . esc_attr( $pending_current ) . '">' . sprintf( esc_html__( 'Pending %s', 'bbpress' ), $pending_count ) . '</a>' . $r['link_after'] 938 $r['link_before'] . '<a href="' . esc_url( $tools_url ) . '" class="' . esc_attr( $all_current ) . '">' . 939 sprintf( 940 /* translators: %s: Number of items */ 941 esc_html__( 'All %s', 'bbpress' ), 942 $all_count 943 ) . 944 '</a>' . $r['link_after'], 945 946 $r['link_before'] . '<a href="' . esc_url( $filter_url ) . '" class="' . esc_attr( $pending_current ) . '">' . 947 sprintf( 948 /* translators: %s: Number of pending items */ 949 esc_html__( 'Pending %s', 'bbpress' ), 950 $pending_count 951 ) . 952 '</a>' . $r['link_after'] 926 953 ); 927 954 -
trunk/src/includes/admin/tools/repair.php
r7357 r7360 84 84 </td> 85 85 <th scope="col" id="description" class="manage-column column-primary column-description sortable <?php echo ( 'priority' === $orderby ) ? esc_attr( $order ) : 'asc'; ?>"> 86 <a href=" 87 <?php 86 <a href="<?php 87 88 88 echo esc_url( 89 89 bbp_get_admin_repair_tool_page_url( … … 94 94 ) 95 95 ); 96 96 97 ?>"> 97 98 <span> 98 <?php 99 esc_html_e( 'Description', 'bbpress' ); 100 ?> 99 <?php esc_html_e( 'Description', 'bbpress' ); ?> 101 100 </span> 102 101 <span class="sorting-indicator"></span> 102 </a> 103 103 </th> 104 104 <th scope="col" id="components" class="manage-column column-components"> … … 106 106 </th> 107 107 <th scope="col" id="overhead" class="manage-column column-overhead sortable <?php echo ( 'overhead' === $orderby ) ? esc_attr( $order ) : 'asc'; ?>"> 108 <a href=" 109 <?php 110 echo esc_url( 111 bbp_get_admin_repair_tool_page_url( 108 <a href="<?php 109 110 echo esc_url( 111 bbp_get_admin_repair_tool_page_url( 112 112 array( 113 113 'orderby' => 'overhead', 114 114 'order' => $new_order 115 ) 116 ) 117 ); 115 ) 116 ) 117 ); 118 118 119 ?>"> 119 120 <span> 120 <?php 121 esc_html_e( 'Overhead', 'bbpress' ); 122 ?> 121 <?php esc_html_e( 'Overhead', 'bbpress' ); ?> 123 122 </span> 124 123 <span class="sorting-indicator"></span> 124 </a> 125 125 </th> 126 126 </tr> … … 138 138 <input type="checkbox" name="checked[]" value="<?php echo esc_attr( $item['id'] ); ?>" id="<?php echo esc_attr( str_replace( '_', '-', $item['id'] ) ); ?>"> 139 139 </th> 140 <td class="bbp-tool-title column-primary column-description" data-colname="<?php esc_html_e( 'Description', 'bbpress' ); ?>">141 <strong><?php echo esc_html( $item['title'] ); ?></strong><?php142 143 // Optional description 144 if ( ! empty( $item['description'] ) ) :145 echo '<p class="description">' . esc_html( $item['description'] ) . '</p>';146 endif;147 148 ?><div class="row-actions hide-if-no-js">140 <td class="bbp-tool-title column-primary column-description" 141 data-colname="<?php esc_html_e( 'Description', 'bbpress' ); ?>"> 142 <strong><?php echo esc_html( $item['title'] ); ?></strong> 143 144 <?php if ( ! empty( $item['description'] ) ) : ?> 145 <p class="description"><?php echo esc_html( $item['description'] ); ?></p> 146 <?php endif; ?> 147 148 <div class="row-actions hide-if-no-js"> 149 149 <span class="run"> 150 <a href="<?php bbp_admin_repair_tool_run_url( $item ); ?>" aria-label="<?php printf( esc_html__( 'Run %s', 'bbpress' ), $item['title'] ); ?>" id="<?php echo esc_attr( $item['id'] ); ?>" ><?php esc_html_e( 'Run', 'bbpress' ); ?></a> 150 <a href="<?php bbp_admin_repair_tool_run_url( $item ); ?>" 151 id="<?php echo esc_attr( $item['id'] ); ?>" 152 aria-label="<?php 153 printf( 154 /* translators: %s: Repair tool title */ 155 esc_html__( 'Run %s', 'bbpress' ), 156 $item['title'] 157 ); 158 ?>"> 159 <?php esc_html_e( 'Run', 'bbpress' ); ?> 160 </a> 151 161 </span> 152 162 </div> 163 153 164 <button type="button" class="toggle-row"> 154 <span class="screen-reader-text"><?php esc_html_e( 'Show more details', 'bbpress' ); ?></span> 165 <span class="screen-reader-text"> 166 <?php esc_html_e( 'Show more details', 'bbpress' ); ?> 167 </span> 155 168 </button> 156 169 </td> … … 225 238 // Define variables 226 239 $bbp_db = bbp_db(); 240 /* translators: %s: Status of the counting process */ 227 241 $statement = esc_html__( 'Counting the number of replies in each topic… %s', 'bbpress' ); 228 242 $result = esc_html__( 'Failed!', 'bbpress' ); … … 274 288 // Define variables 275 289 $bbp_db = bbp_db(); 290 /* translators: %s: Status of the counting process */ 276 291 $statement = esc_html__( 'Counting the number of voices in each topic… %s', 'bbpress' ); 277 292 $result = esc_html__( 'Failed!', 'bbpress' ); … … 326 341 // Define variables 327 342 $bbp_db = bbp_db(); 343 /* translators: %s: Status of the counting process */ 328 344 $statement = esc_html__( 'Counting the number of pending, spammed, and trashed replies in each topic… %s', 'bbpress' ); 329 345 $result = esc_html__( 'Failed!', 'bbpress' ); … … 360 376 // Define variables 361 377 $bbp_db = bbp_db(); 378 /* translators: %s: Status of the counting process */ 362 379 $statement = esc_html__( 'Counting the number of topics in each forum… %s', 'bbpress' ); 363 380 $result = esc_html__( 'Failed!', 'bbpress' ); … … 391 408 392 409 // Define variables 410 /* translators: %s: Status of the counting process */ 393 411 $statement = esc_html__( 'Counting the number of topics in each topic-tag… %s', 'bbpress' ); 394 412 $result = esc_html__( 'Failed!', 'bbpress' ); … … 436 454 // Define variables 437 455 $bbp_db = bbp_db(); 456 /* translators: %s: Status of the counting process */ 438 457 $statement = esc_html__( 'Counting the number of replies in each forum… %s', 'bbpress' ); 439 458 $result = esc_html__( 'Failed!', 'bbpress' ); … … 478 497 // Define variables 479 498 $bbp_db = bbp_db(); 499 /* translators: %s: Status of the counting process */ 480 500 $statement = esc_html__( 'Counting the number of pending, spammed, and trashed replies in each forum… %s', 'bbpress' ); 481 501 $result = esc_html__( 'Failed!', 'bbpress' ); … … 519 539 // Define variables 520 540 $bbp_db = bbp_db(); 541 /* translators: %s: Status of the counting process */ 521 542 $statement = esc_html__( 'Counting the number of topics each user has created… %s', 'bbpress' ); 522 543 $result = esc_html__( 'Failed!', 'bbpress' ); … … 569 590 // Define variables 570 591 $bbp_db = bbp_db(); 592 /* translators: %s: Status of the counting process */ 571 593 $statement = esc_html__( 'Counting the number of topics to which each user has replied… %s', 'bbpress' ); 572 594 $result = esc_html__( 'Failed!', 'bbpress' ); … … 619 641 // Define variables 620 642 $bbp_db = bbp_db(); 643 /* translators: %s: Status of the repair process */ 621 644 $statement = esc_html__( 'Removing unpublished topics from user favorites… %s', 'bbpress' ); 622 645 $result = esc_html__( 'Failed!', 'bbpress' ); … … 689 712 // Define variables 690 713 $bbp_db = bbp_db(); 714 /* translators: %s: Status of the repair process */ 691 715 $statement = esc_html__( 'Removing trashed topics from user subscriptions… %s', 'bbpress' ); 692 716 $result = esc_html__( 'Failed!', 'bbpress' ); … … 758 782 // Define variables 759 783 $bbp_db = bbp_db(); 784 /* translators: %s: Status of the repair process */ 760 785 $statement = esc_html__( 'Removing trashed forums from user subscriptions… %s', 'bbpress' ); 761 786 $result = esc_html__( 'Failed!', 'bbpress' ); … … 824 849 */ 825 850 function bbp_admin_repair_user_roles() { 826 851 /* translators: %s: Status of the repair process */ 827 852 $statement = esc_html__( 'Remapping forum role for each user on this site… %s', 'bbpress' ); 828 853 $changed = 0; … … 922 947 } 923 948 } 924 949 /* translators: %s: Number of updated users */ 925 950 $result = sprintf( esc_html__( 'Complete! %s users updated.', 'bbpress' ), bbp_number_format( $changed ) ); 926 951 … … 939 964 // Define variables 940 965 $bbp_db = bbp_db(); 966 /* translators: %s: Status of the repair process */ 941 967 $statement = esc_html__( 'Recomputing latest post in every topic and forum… %s', 'bbpress' ); 942 968 $result = esc_html__( 'Failed!', 'bbpress' ); … … 1060 1086 // Define variables 1061 1087 $bbp_db = bbp_db(); 1088 /* translators: %s: Status of the repair process */ 1062 1089 $statement = esc_html__( 'Repairing the sticky topic to the parent forum relationships… %s', 'bbpress' ); 1063 1090 $result = esc_html__( 'Failed!', 'bbpress' ); … … 1125 1152 // Define variables 1126 1153 $bbp_db = bbp_db(); 1154 /* translators: %s: Status of the repair process */ 1127 1155 $statement = esc_html__( 'Repairing closed topics… %s', 'bbpress' ); 1128 1156 $result = esc_html__( 'No closed topics to repair.', 'bbpress' ); … … 1156 1184 1157 1185 // Complete results 1186 /* translators: %d: Number of repaired topics */ 1158 1187 $result = sprintf( _n( 'Complete! %d closed topic repaired.', 'Complete! %d closed topics repaired.', $changed, 'bbpress' ), $changed ); 1159 1188 … … 1169 1198 */ 1170 1199 function bbp_admin_repair_forum_visibility() { 1200 /* translators: %s: Status of the repair process */ 1171 1201 $statement = esc_html__( 'Recalculating forum visibility… %s', 'bbpress' ); 1172 1202 … … 1192 1222 // Define variables 1193 1223 $bbp_db = bbp_db(); 1224 /* translators: %s: Status of the repair process */ 1194 1225 $statement = esc_html__( 'Recalculating the forum for each post… %s', 'bbpress' ); 1195 1226 $result = esc_html__( 'Failed!', 'bbpress' ); … … 1254 1285 // Define variables 1255 1286 $bbp_db = bbp_db(); 1287 /* translators: %s: Status of the repair process */ 1256 1288 $statement = esc_html__( 'Recalculating the topic for each post… %s', 'bbpress' ); 1257 1289 $result = esc_html__( 'Failed!', 'bbpress' ); … … 1305 1337 // Define variables 1306 1338 $bbp_db = bbp_db(); 1339 /* translators: %s: Status of the repair process */ 1307 1340 $statement = esc_html__( 'Recalculating reply menu order… %s', 'bbpress' ); 1308 1341 $result = esc_html__( 'No reply positions to recalculate.', 'bbpress' ); -
trunk/src/includes/admin/tools/reset.php
r7006 r7360 180 180 $messages[] = bbp_admin_reset_query_feedback( array( 181 181 'query' => "DELETE FROM `{$bbp_db->posts}` WHERE `post_type` IN ('{$fpt}', '{$tpt}', '{$rpt}')", 182 /* translators: %s: Status of the deletion process */ 182 183 'message' => esc_html__( 'Removing Forums, Topics, and Replies… %s', 'bbpress' ) 183 184 ) ); … … 188 189 $messages[] = bbp_admin_reset_query_feedback( array( 189 190 'query' => "DELETE FROM `{$bbp_db->postmeta}` WHERE `post_id` IN ('{$sql_meta}')", 191 /* translators: %s: Status of the meta deletion process */ 190 192 'message' => esc_html__( 'Removing Forum, Topic, and Reply Meta Data… %s', 'bbpress' ) 191 193 ) ); … … 197 199 $messages[] = bbp_admin_reset_query_feedback( array( 198 200 'query' => "DELETE FROM `{$bbp_db->posts}` WHERE `post_parent` IN ('{$sql_meta}') AND `post_type` = 'revision'", 201 /* translators: %s: Status of the revision deletion process */ 199 202 'message' => esc_html__( 'Removing Revision Data… %s', 'bbpress' ) 200 203 ) ); … … 202 205 } 203 206 204 / ** Topic Tags ************************************************************/207 // Topic Tags 205 208 206 209 $messages[] = bbp_admin_reset_query_feedback( array( 207 210 'query' => "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'topic-tag'", 211 /* translators: %s: Status of the tag deletion process */ 208 212 'message' => esc_html__( 'Deleting Topic Tags… %s', 'bbpress' ) 209 213 ) ); 210 214 211 / ** User ******************************************************************/215 // User 212 216 213 217 // First, if we're deleting previously imported users, delete them now … … 225 229 $messages[] = bbp_admin_reset_query_feedback( array( 226 230 'query' => "DELETE FROM `{$bbp_db->users}` WHERE `ID` IN ('{$sql_meta}')", 231 /* translators: %s: Status of the user deletion process */ 227 232 'message' => esc_html__( 'Deleting Imported Users… %s', 'bbpress' ) 228 233 ) ); … … 231 236 $messages[] = bbp_admin_reset_query_feedback( array( 232 237 'query' => "DELETE FROM `{$bbp_db->usermeta}` WHERE `user_id` IN ('{$sql_meta}')", 238 /* translators: %s: Status of the user meta deletion process */ 233 239 'message' => esc_html__( 'Deleting Imported User Meta… %s', 'bbpress' ) 234 240 ) ); … … 239 245 $messages[] = bbp_admin_reset_query_feedback( array( 240 246 'query' => "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%'", 247 /* translators: %s: Status of the user meta deletion process */ 241 248 'message' => esc_html__( 'Deleting bbPress Specific User Meta… %s', 'bbpress' ) 242 249 ) ); 243 250 244 / ** Converter *************************************************************/251 // Converter 245 252 246 253 $table_name = $bbp_db->prefix . 'bbp_converter_translator'; … … 248 255 $messages[] = bbp_admin_reset_query_feedback( array( 249 256 'query' => "DROP TABLE {$table_name}", 257 /* translators: %s: Status of the table deletion process */ 250 258 'message' => esc_html__( 'Dropping Conversion Table… %s', 'bbpress' ) 251 259 ) ); 252 260 } 253 261 254 / ** Options ***************************************************************/262 // Options 255 263 256 264 bbp_delete_options(); 257 265 $messages[] = esc_html__( 'Deleting Settings… Success!', 'bbpress' ); 258 266 259 / ** Roles *****************************************************************/267 // Roles 260 268 261 269 bbp_remove_roles(); … … 263 271 $messages[] = esc_html__( 'Removing Roles and Capabilities… Success!', 'bbpress' ); 264 272 265 / ** Output ****************************************************************/273 // Output 266 274 267 275 if ( count( $messages ) ) { -
trunk/src/includes/admin/tools/upgrade.php
r7357 r7360 157 157 ?><div class="row-actions hide-if-no-js"> 158 158 <span class="run"> 159 <a href="<?php bbp_admin_repair_tool_run_url( $item ); ?>" aria-label="<?php printf( esc_html__( 'Run %s', 'bbpress' ), $item['title'] ); ?>" id="<?php echo esc_attr( $item['id'] ); ?>" ><?php esc_html_e( 'Run', 'bbpress' ); ?></a> 159 <a href="<?php bbp_admin_repair_tool_run_url( $item ); ?>" 160 id="<?php echo esc_attr( $item['id'] ); ?>" 161 aria-label="<?php 162 printf( 163 /* translators: %s: Repair tool title */ 164 esc_html__( 'Run %s', 'bbpress' ), 165 $item['title'] 166 ); 167 ?>"> 168 <?php esc_html_e( 'Run', 'bbpress' ); ?> 169 </a> 160 170 </span> 161 171 </div> … … 242 252 // Define variables 243 253 $bbp_db = bbp_db(); 254 /* translators: %s: Status of the upgrade process */ 244 255 $statement = esc_html__( 'Upgrading user engagements… %s', 'bbpress' ); 245 256 $result = esc_html__( 'No engagements to upgrade.', 'bbpress' ); … … 276 287 277 288 // Complete results 289 /* translators: %d: Number of upgraded engagements */ 278 290 $result = sprintf( _n( 'Complete! %d engagement upgraded.', 'Complete! %d engagements upgraded.', $engagements, 'bbpress' ), bbp_number_format( $engagements ) ); 279 291 … … 294 306 // Define variables 295 307 $bbp_db = bbp_db(); 308 /* translators: %s: Status of the upgrade process */ 296 309 $statement = esc_html__( 'Upgrading BuddyPress group-forum relationships… %s', 'bbpress' ); 297 310 $g_count = 0; … … 415 428 416 429 // Complete results 417 $result = sprintf( esc_html__( 'Complete! %1$s groups updated; %2$s forums updated; %3$s forum statuses synced.', 'bbpress' ), bbp_number_format( $g_count ), bbp_number_format( $f_count ), bbp_number_format( $s_count ) ); 430 $result = sprintf( 431 /* translators: %1$s: Number of groups updated; %2$s: Number of forums updated; %3$s: Number of forum statuses synced */ 432 esc_html__( 'Complete! %1$s groups updated; %2$s forums updated; %3$s forum statuses synced.', 'bbpress' ), 433 bbp_number_format( $g_count ), 434 bbp_number_format( $f_count ), 435 bbp_number_format( $s_count ) 436 ); 418 437 return array( 0, sprintf( $statement, $result ) ); 419 438 } … … 430 449 // Define variables 431 450 $bbp_db = bbp_db(); 451 /* translators: %s: Status of the upgrade process */ 432 452 $statement = esc_html__( 'Upgrading user favorites… %s', 'bbpress' ); 433 453 $result = esc_html__( 'No favorites to upgrade.', 'bbpress' ); … … 474 494 475 495 // Complete results 496 /* translators: %d: Number of upgraded favorites */ 476 497 $result = sprintf( _n( 'Complete! %d favorite upgraded.', 'Complete! %d favorites upgraded.', $total, 'bbpress' ), bbp_number_format( $total ) ); 477 498 … … 490 511 // Define variables 491 512 $bbp_db = bbp_db(); 513 /* translators: %s: Status of the upgrade process */ 492 514 $statement = esc_html__( 'Upgrading user topic subscriptions… %s', 'bbpress' ); 493 515 $result = esc_html__( 'No topic subscriptions to upgrade.', 'bbpress' ); … … 534 556 535 557 // Complete results 558 /* translators: %d: Number of upgraded topic subscriptions */ 536 559 $result = sprintf( _n( 'Complete! %d topic subscription upgraded.', 'Complete! %d topic subscriptions upgraded.', $total, 'bbpress' ), bbp_number_format( $total ) ); 537 560 … … 550 573 // Define variables 551 574 $bbp_db = bbp_db(); 575 /* translators: %s: Status of the upgrade process */ 552 576 $statement = esc_html__( 'Upgrading user forum subscriptions… %s', 'bbpress' ); 553 577 $result = esc_html__( 'No forum subscriptions to upgrade.', 'bbpress' ); … … 594 618 595 619 // Complete results 620 /* translators: %d: Number of upgraded forum subscriptions */ 596 621 $result = sprintf( _n( 'Complete! %d forum subscription upgraded.', 'Complete! %d forum subscriptions upgraded.', $total, 'bbpress' ), bbp_number_format( $total ) ); 597 622 … … 610 635 // Define variables 611 636 $bbp_db = bbp_db(); 637 /* translators: %s: Status of the upgrade process */ 612 638 $statement = esc_html__( 'Remove favorites from usermeta… %s', 'bbpress' ); 613 639 $result = esc_html__( 'No favorites to remove.', 'bbpress' ); … … 630 656 631 657 // Complete results 658 /* translators: %d: Number of deleted favorites */ 632 659 $result = sprintf( _n( 'Complete! %d favorite deleted.', 'Complete! %d favorites deleted.', $total, 'bbpress' ), bbp_number_format( $total ) ); 633 660 … … 646 673 // Define variables 647 674 $bbp_db = bbp_db(); 675 /* translators: %s: Status of the upgrade process */ 648 676 $statement = esc_html__( 'Remove topic subscriptions from usermeta… %s', 'bbpress' ); 649 677 $result = esc_html__( 'No topic subscriptions to remove.', 'bbpress' ); … … 666 694 667 695 // Complete results 696 /* translators: %d: Number of deleted topic subscriptions */ 668 697 $result = sprintf( _n( 'Complete! %d topic subscription deleted.', 'Complete! %d topic subscriptions deleted.', $total, 'bbpress' ), bbp_number_format( $total ) ); 669 698 … … 682 711 // Define variables 683 712 $bbp_db = bbp_db(); 713 /* translators: %s: Status of the upgrade process */ 684 714 $statement = esc_html__( 'Remove forum subscriptions from usermeta… %s', 'bbpress' ); 685 715 $result = esc_html__( 'No forum subscriptions to remove.', 'bbpress' ); … … 702 732 703 733 // Complete results 734 /* translators: %d: Number of deleted forum subscriptions */ 704 735 $result = sprintf( _n( 'Complete! %d forum subscription deleted.', 'Complete! %d forum subscriptions deleted.', $total, 'bbpress' ), bbp_number_format( $total ) ); 705 736 -
trunk/src/includes/admin/topics.php
r7359 r7360 21 21 class BBP_Topics_Admin { 22 22 23 /** Variables *************************************************************/24 25 /**26 * @var The post type of this admin component27 */28 private $post_type = '';29 30 /** Functions *************************************************************/31 32 /**33 * The main bbPress topics admin loader34 *35 * @since 2.0.0 bbPress (r2515)36 */37 public function __construct() {38 $this->setup_globals();39 $this->setup_actions();40 }41 42 /**43 * Setup the admin hooks, actions and filters44 *45 * @since 2.0.0 bbPress (r2646)46 * @since 2.6.0 bbPress (r6101) Added bulk actions47 *48 * @access private49 */50 private function setup_actions() {51 52 // Messages53 add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) );54 55 // Topic bulk actions, added in WordPress 4.7, see #WP16031.56 if ( bbp_get_major_wp_version() >= 4.7 ) {57 add_filter( 'bulk_actions-edit-topic', array( $this, 'bulk_actions' ) );58 add_filter( 'handle_bulk_actions-edit-topic', array( $this, 'handle_bulk_actions' ), 10, 3 );59 add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_post_updated_messages' ), 10, 2 );60 }61 62 // Topic column headers.63 add_filter( 'manage_' . $this->post_type . '_posts_columns', array( $this, 'column_headers' ) );64 65 // Topic columns (in post row)66 add_action( 'manage_' . $this->post_type . '_posts_custom_column', array( $this, 'column_data' ), 10, 2 );67 add_filter( 'post_row_actions', array( $this, 'row_actions' ), 10, 2 );68 69 // Topic meta-box actions70 add_action( 'add_meta_boxes', array( $this, 'attributes_metabox' ) );71 add_action( 'add_meta_boxes', array( $this, 'author_metabox' ) );72 add_action( 'add_meta_boxes', array( $this, 'replies_metabox' ) );73 add_action( 'add_meta_boxes', array( $this, 'engagements_metabox' ) );74 add_action( 'add_meta_boxes', array( $this, 'favorites_metabox' ) );75 add_action( 'add_meta_boxes', array( $this, 'subscriptions_metabox' ) );76 add_action( 'add_meta_boxes', array( $this, 'comments_metabox' ) );77 add_action( 'save_post', array( $this, 'save_meta_boxes' ) );78 79 // Check if there are any bbp_toggle_topic_* requests on admin_init, also have a message displayed80 add_action( 'load-edit.php', array( $this, 'toggle_topic' ) );81 add_action( 'load-edit.php', array( $this, 'toggle_topic_notice' ) );82 83 // Add ability to filter topics and replies per forum84 add_filter( 'restrict_manage_posts', array( $this, 'filter_dropdown' ) );85 add_filter( 'bbp_request', array( $this, 'filter_post_rows' ) );86 87 // Empty spam88 add_filter( 'manage_posts_extra_tablenav', array( $this, 'filter_empty_spam' ) );89 90 // Contextual Help91 add_action( 'load-edit.php', array( $this, 'edit_help' ) );92 add_action( 'load-post.php', array( $this, 'new_help' ) );93 add_action( 'load-post-new.php', array( $this, 'new_help' ) );94 }95 96 /**97 * Admin globals98 *99 * @since 2.0.0 bbPress (r2646)100 *101 * @access private102 */103 private function setup_globals() {104 $this->post_type = bbp_get_topic_post_type();105 }106 107 /** Contextual Help *******************************************************/108 109 /**110 * Contextual help for bbPress topic edit page111 *112 * @since 2.0.0 bbPress (r3119)113 */114 public function edit_help() {115 116 // Overview117 get_current_screen()->add_help_tab( array(23 /** Variables *************************************************************/ 24 25 /** 26 * @var The post type of this admin component 27 */ 28 private $post_type = ''; 29 30 /** Functions *************************************************************/ 31 32 /** 33 * The main bbPress topics admin loader 34 * 35 * @since 2.0.0 bbPress (r2515) 36 */ 37 public function __construct() { 38 $this->setup_globals(); 39 $this->setup_actions(); 40 } 41 42 /** 43 * Setup the admin hooks, actions and filters 44 * 45 * @since 2.0.0 bbPress (r2646) 46 * @since 2.6.0 bbPress (r6101) Added bulk actions 47 * 48 * @access private 49 */ 50 private function setup_actions() { 51 52 // Messages 53 add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) ); 54 55 // Topic bulk actions, added in WordPress 4.7, see #WP16031. 56 if ( bbp_get_major_wp_version() >= 4.7 ) { 57 add_filter( 'bulk_actions-edit-topic', array( $this, 'bulk_actions' ) ); 58 add_filter( 'handle_bulk_actions-edit-topic', array( $this, 'handle_bulk_actions' ), 10, 3 ); 59 add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_post_updated_messages' ), 10, 2 ); 60 } 61 62 // Topic column headers. 63 add_filter( 'manage_' . $this->post_type . '_posts_columns', array( $this, 'column_headers' ) ); 64 65 // Topic columns (in post row) 66 add_action( 'manage_' . $this->post_type . '_posts_custom_column', array( $this, 'column_data' ), 10, 2 ); 67 add_filter( 'post_row_actions', array( $this, 'row_actions' ), 10, 2 ); 68 69 // Topic meta-box actions 70 add_action( 'add_meta_boxes', array( $this, 'attributes_metabox' ) ); 71 add_action( 'add_meta_boxes', array( $this, 'author_metabox' ) ); 72 add_action( 'add_meta_boxes', array( $this, 'replies_metabox' ) ); 73 add_action( 'add_meta_boxes', array( $this, 'engagements_metabox' ) ); 74 add_action( 'add_meta_boxes', array( $this, 'favorites_metabox' ) ); 75 add_action( 'add_meta_boxes', array( $this, 'subscriptions_metabox' ) ); 76 add_action( 'add_meta_boxes', array( $this, 'comments_metabox' ) ); 77 add_action( 'save_post', array( $this, 'save_meta_boxes' ) ); 78 79 // Check if there are any bbp_toggle_topic_* requests on admin_init, also have a message displayed 80 add_action( 'load-edit.php', array( $this, 'toggle_topic' ) ); 81 add_action( 'load-edit.php', array( $this, 'toggle_topic_notice' ) ); 82 83 // Add ability to filter topics and replies per forum 84 add_filter( 'restrict_manage_posts', array( $this, 'filter_dropdown' ) ); 85 add_filter( 'bbp_request', array( $this, 'filter_post_rows' ) ); 86 87 // Empty spam 88 add_filter( 'manage_posts_extra_tablenav', array( $this, 'filter_empty_spam' ) ); 89 90 // Contextual Help 91 add_action( 'load-edit.php', array( $this, 'edit_help' ) ); 92 add_action( 'load-post.php', array( $this, 'new_help' ) ); 93 add_action( 'load-post-new.php', array( $this, 'new_help' ) ); 94 } 95 96 /** 97 * Admin globals 98 * 99 * @since 2.0.0 bbPress (r2646) 100 * 101 * @access private 102 */ 103 private function setup_globals() { 104 $this->post_type = bbp_get_topic_post_type(); 105 } 106 107 /** Contextual Help *******************************************************/ 108 109 /** 110 * Contextual help for bbPress topic edit page 111 * 112 * @since 2.0.0 bbPress (r3119) 113 */ 114 public function edit_help() { 115 116 // Overview 117 get_current_screen()->add_help_tab( array( 118 118 'id' => 'overview', 119 119 'title' => __( 'Overview', 'bbpress' ), 120 120 'content' => 121 121 '<p>' . __( 'This screen displays the individual topics on your site. You can customize the display of this screen to suit your workflow.', 'bbpress' ) . '</p>' 122 ) );123 124 // Screen Content125 get_current_screen()->add_help_tab( array(122 ) ); 123 124 // Screen Content 125 get_current_screen()->add_help_tab( array( 126 126 'id' => 'screen-content', 127 127 'title' => __( 'Screen Content', 'bbpress' ), … … 134 134 '<li>' . __( 'You can refine the list to show only topics in a specific forum or from a specific month by using the dropdown menus above the topics list. Click the Filter button after making your selection.', 'bbpress' ) . '</li>' . 135 135 '</ul>' 136 ) );137 138 // Available Actions139 get_current_screen()->add_help_tab( array(136 ) ); 137 138 // Available Actions 139 get_current_screen()->add_help_tab( array( 140 140 'id' => 'action-links', 141 141 'title' => __( 'Available Actions', 'bbpress' ), … … 152 152 '<li>' . __( '<strong>View</strong> will take you to your live site to view the topic.', 'bbpress' ) . '</li>' . 153 153 '</ul>' 154 ) );155 156 // Bulk Actions157 get_current_screen()->add_help_tab( array(154 ) ); 155 156 // Bulk Actions 157 get_current_screen()->add_help_tab( array( 158 158 'id' => 'bulk-actions', 159 159 'title' => __( 'Bulk Actions', 'bbpress' ), … … 161 161 '<p>' . __( 'You can also edit, spam, or move multiple topics to the trash at once. Select the topics you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.', 'bbpress' ) . '</p>' . 162 162 '<p>' . __( 'When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected topics at once. To remove a topic from the grouping, just click the x next to its name in the Bulk Edit area that appears.', 'bbpress' ) . '</p>' 163 ) );164 165 // Help Sidebar166 get_current_screen()->set_help_sidebar(163 ) ); 164 165 // Help Sidebar 166 get_current_screen()->set_help_sidebar( 167 167 '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' . 168 168 '<p>' . __( '<a href="https://codex.bbpress.org" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' . 169 169 '<p>' . __( '<a href="https://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>', 'bbpress' ) . '</p>' 170 );171 }172 173 /**174 * Contextual help for bbPress topic edit page175 *176 * @since 2.0.0 bbPress (r3119)177 */178 public function new_help() {179 180 $customize_display = '<p>' . __( 'The title field and the big topic editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.', 'bbpress' ) . '</p>';181 182 get_current_screen()->add_help_tab( array(170 ); 171 } 172 173 /** 174 * Contextual help for bbPress topic edit page 175 * 176 * @since 2.0.0 bbPress (r3119) 177 */ 178 public function new_help() { 179 180 $customize_display = '<p>' . __( 'The title field and the big topic editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.', 'bbpress' ) . '</p>'; 181 182 get_current_screen()->add_help_tab( array( 183 183 'id' => 'customize-display', 184 184 'title' => __( 'Customizing This Display', 'bbpress' ), 185 185 'content' => $customize_display, 186 ) );187 188 get_current_screen()->add_help_tab( array(186 ) ); 187 188 get_current_screen()->add_help_tab( array( 189 189 'id' => 'title-topic-editor', 190 190 'title' => __( 'Title and Topic Editor', 'bbpress' ), … … 192 192 '<p>' . __( '<strong>Title</strong> - Enter a title for your topic. After you enter a title, you’ll see the permalink below, which you can edit.', 'bbpress' ) . '</p>' . 193 193 '<p>' . __( '<strong>Topic Editor</strong> - Enter the text for your topic. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your topic text. You can insert media files by clicking the icons above the topic editor and following the directions. You can go to the distraction-free writing screen via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in HTML mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular topic editor.', 'bbpress' ) . '</p>' 194 ) );195 196 $publish_box = '<p>' . __( '<strong>Publish</strong> - You can set the terms of publishing your topic in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a topic or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a topic to be published in the future or backdate a topic.', 'bbpress' ) . '</p>';197 198 if ( current_theme_supports( 'topic-thumbnails' ) && post_type_supports( bbp_get_topic_post_type(), 'thumbnail' ) ) {199 $publish_box .= '<p>' . __( '<strong>Featured Image</strong> - This allows you to associate an image with your topic without inserting it. This is usually useful only if your theme makes use of the featured image as a topic thumbnail on the home page, a custom header, etc.', 'bbpress' ) . '</p>';200 }201 202 get_current_screen()->add_help_tab( array(194 ) ); 195 196 $publish_box = '<p>' . __( '<strong>Publish</strong> - You can set the terms of publishing your topic in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a topic or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a topic to be published in the future or backdate a topic.', 'bbpress' ) . '</p>'; 197 198 if ( current_theme_supports( 'topic-thumbnails' ) && post_type_supports( bbp_get_topic_post_type(), 'thumbnail' ) ) { 199 $publish_box .= '<p>' . __( '<strong>Featured Image</strong> - This allows you to associate an image with your topic without inserting it. This is usually useful only if your theme makes use of the featured image as a topic thumbnail on the home page, a custom header, etc.', 'bbpress' ) . '</p>'; 200 } 201 202 get_current_screen()->add_help_tab( array( 203 203 'id' => 'topic-attributes', 204 204 'title' => __( 'Topic Attributes', 'bbpress' ), … … 209 209 '<li>' . __( '<strong>Topic Type</strong> dropdown indicates the sticky status of the topic. Selecting the super sticky option would stick the topic to the front of your forums, i.e. the topic index, sticky option would stick the topic to its respective forum. Selecting normal would not stick the topic anywhere.', 'bbpress' ) . '</li>' . 210 210 '</ul>' 211 ) );212 213 get_current_screen()->add_help_tab( array(211 ) ); 212 213 get_current_screen()->add_help_tab( array( 214 214 'id' => 'publish-box', 215 215 'title' => __( 'Publish Box', 'bbpress' ), 216 216 'content' => $publish_box, 217 ) );218 219 get_current_screen()->set_help_sidebar(217 ) ); 218 219 get_current_screen()->set_help_sidebar( 220 220 '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' . 221 221 '<p>' . __( '<a href="https://codex.bbpress.org" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' . 222 222 '<p>' . __( '<a href="https://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>', 'bbpress' ) . '</p>' 223 ); 223 ); 224 } 225 226 /** 227 * Add spam/unspam bulk actions to the bulk action dropdown. 228 * 229 * @since 2.6.0 bbPress (r6101) 230 * 231 * @param array $actions The list of bulk actions. 232 * @return array The filtered list of bulk actions. 233 */ 234 public function bulk_actions( $actions ) { 235 236 if ( current_user_can( 'moderate' ) ) { 237 if ( bbp_get_spam_status_id() === get_query_var( 'post_status' ) ) { 238 $actions['unspam'] = esc_html__( 'Unspam', 'bbpress' ); 239 } else { 240 $actions['spam'] = esc_html__( 'Spam', 'bbpress' ); 224 241 } 225 226 /** 227 * Add spam/unspam bulk actions to the bulk action dropdown. 228 * 229 * @since 2.6.0 bbPress (r6101) 230 * 231 * @param array $actions The list of bulk actions. 232 * @return array The filtered list of bulk actions. 233 */ 234 public function bulk_actions( $actions ) { 235 236 if ( current_user_can( 'moderate' ) ) { 237 if ( bbp_get_spam_status_id() === get_query_var( 'post_status' ) ) { 238 $actions['unspam'] = esc_html__( 'Unspam', 'bbpress' ); 239 } else { 240 $actions['spam'] = esc_html__( 'Spam', 'bbpress' ); 242 } 243 244 return $actions; 245 } 246 247 /** 248 * Add custom bulk action updated messages for topics. 249 * 250 * @since 2.6.0 bbPress (r6101) 251 * 252 * @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type. 253 * @param array $bulk_counts Array of item counts for each message, used to build internationalized strings. 254 */ 255 public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) { 256 /* translators: %s: Number of topics */ 257 $bulk_messages['topic']['updated'] = _n( '%s topic updated.', '%s topics updated.', $bulk_counts['updated'], 'bbpress' ); 258 $bulk_messages['topic']['locked'] = ( 1 === $bulk_counts['locked'] ) 259 ? __( '1 topic not updated, somebody is editing it.', 'bbpress' ) 260 /* translators: %s: Number of topics */ 261 : _n( '%s topic not updated, somebody is editing it.', '%s topics not updated, somebody is editing them.', $bulk_counts['locked'], 'bbpress' ); 262 263 return $bulk_messages; 264 } 265 266 /** 267 * Handle spam/unspam bulk actions. 268 * 269 * @since 2.6.0 bbPress (r6101) 270 * 271 * @param string $sendback The sendback URL. 272 * @param string $doaction The action to be taken. 273 * @param array $post_ids The post IDS to take the action on. 274 * @return string The sendback URL. 275 */ 276 public function handle_bulk_actions( $sendback, $doaction, $post_ids ) { 277 278 $sendback = remove_query_arg( array( 'spam', 'unspam' ), $sendback ); 279 $updated = $locked = 0; 280 281 if ( 'spam' === $doaction ) { 282 283 foreach ( (array) $post_ids as $post_id ) { 284 if ( ! current_user_can( 'moderate', $post_id ) ) { 285 wp_die( esc_html__( 'Sorry, you are not allowed to spam this item.', 'bbpress' ) ); 241 286 } 287 288 if ( wp_check_post_lock( $post_id ) ) { 289 $locked++; 290 continue; 291 } 292 293 if ( ! bbp_spam_topic( $post_id ) ) { 294 wp_die( esc_html__( 'Error in spamming topic.', 'bbpress' ) ); 295 } 296 297 $updated++; 242 298 } 243 299 244 return $actions; 245 } 246 247 /** 248 * Add custom bulk action updated messages for topics. 249 * 250 * @since 2.6.0 bbPress (r6101) 251 * 252 * @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type. 253 * @param array $bulk_counts Array of item counts for each message, used to build internationalized strings. 254 */ 255 public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) { 256 $bulk_messages['topic']['updated'] = _n( '%s topic updated.', '%s topics updated.', $bulk_counts['updated'], 'bbpress' ); 257 $bulk_messages['topic']['locked'] = ( 1 === $bulk_counts['locked'] ) 258 ? __( '1 topic not updated, somebody is editing it.', 'bbpress' ) 259 : _n( '%s topic not updated, somebody is editing it.', '%s topics not updated, somebody is editing them.', $bulk_counts['locked'], 'bbpress' ); 260 261 return $bulk_messages; 262 } 263 264 /** 265 * Handle spam/unspam bulk actions. 266 * 267 * @since 2.6.0 bbPress (r6101) 268 * 269 * @param string $sendback The sendback URL. 270 * @param string $doaction The action to be taken. 271 * @param array $post_ids The post IDS to take the action on. 272 * @return string The sendback URL. 273 */ 274 public function handle_bulk_actions( $sendback, $doaction, $post_ids ) { 275 276 $sendback = remove_query_arg( array( 'spam', 'unspam' ), $sendback ); 277 $updated = $locked = 0; 278 279 if ( 'spam' === $doaction ) { 280 281 foreach ( (array) $post_ids as $post_id ) { 282 if ( ! current_user_can( 'moderate', $post_id ) ) { 283 wp_die( esc_html__( 'Sorry, you are not allowed to spam this item.', 'bbpress' ) ); 284 } 285 286 if ( wp_check_post_lock( $post_id ) ) { 287 $locked++; 288 continue; 289 } 290 291 if ( ! bbp_spam_topic( $post_id ) ) { 292 wp_die( esc_html__( 'Error in spamming topic.', 'bbpress' ) ); 293 } 294 295 $updated++; 296 } 297 298 $sendback = add_query_arg( array( 300 $sendback = add_query_arg( array( 299 301 'updated' => $updated, 300 302 'ids' => implode( ',', $post_ids ), 301 303 'locked' => $locked 302 ), $sendback ); 303 304 } elseif ( 'unspam' === $doaction ) { 305 306 foreach ( (array) $post_ids as $post_id ) { 307 if ( ! current_user_can( 'moderate', $post_id ) ) { 308 wp_die( esc_html__( 'Sorry, you are not allowed to unspam this topic.', 'bbpress' ) ); 309 } 310 311 if ( wp_check_post_lock( $post_id ) ) { 312 $locked++; 313 continue; 314 } 315 316 if ( ! bbp_unspam_topic( $post_id ) ) { 317 wp_die( esc_html__( 'Error in unspamming topic.', 'bbpress' ) ); 318 } 319 320 $updated++; 304 ), $sendback ); 305 306 } elseif ( 'unspam' === $doaction ) { 307 308 foreach ( (array) $post_ids as $post_id ) { 309 if ( ! current_user_can( 'moderate', $post_id ) ) { 310 wp_die( esc_html__( 'Sorry, you are not allowed to unspam this topic.', 'bbpress' ) ); 321 311 } 322 312 323 $sendback = add_query_arg( array( 313 if ( wp_check_post_lock( $post_id ) ) { 314 $locked++; 315 continue; 316 } 317 318 if ( ! bbp_unspam_topic( $post_id ) ) { 319 wp_die( esc_html__( 'Error in unspamming topic.', 'bbpress' ) ); 320 } 321 322 $updated++; 323 } 324 325 $sendback = add_query_arg( array( 324 326 'updated' => $updated, 325 327 'ids' => implode( ',', $post_ids ), 326 328 'locked' => $locked 327 ), $sendback );328 }329 330 return $sendback;331 }332 333 /**334 * Add the topic attributes meta-box335 *336 * @since 2.0.0 bbPress (r2744)337 */338 public function attributes_metabox() {339 add_meta_box(329 ), $sendback ); 330 } 331 332 return $sendback; 333 } 334 335 /** 336 * Add the topic attributes meta-box 337 * 338 * @since 2.0.0 bbPress (r2744) 339 */ 340 public function attributes_metabox() { 341 add_meta_box( 340 342 'bbp_topic_attributes', 341 343 esc_html__( 'Topic Attributes', 'bbpress' ), … … 344 346 'side', 345 347 'high' 346 );347 }348 349 /**350 * Add the author info meta-box351 *352 * @since 2.0.0 bbPress (r2828)353 */354 public function author_metabox() {355 356 // Bail if post_type is not a topic357 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {358 return;359 }360 361 // Add the meta-box362 add_meta_box(348 ); 349 } 350 351 /** 352 * Add the author info meta-box 353 * 354 * @since 2.0.0 bbPress (r2828) 355 */ 356 public function author_metabox() { 357 358 // Bail if post_type is not a topic 359 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) { 360 return; 361 } 362 363 // Add the meta-box 364 add_meta_box( 363 365 'bbp_author_metabox', 364 366 esc_html__( 'Author Information', 'bbpress' ), … … 367 369 'side', 368 370 'high' 369 );370 }371 372 /**373 * Add the replies meta-box374 *375 * Allows viewing & moderating of replies to a topic, based on the way376 * comments are visible on a blog post.377 *378 * @since 2.6.0 bbPress (r5886)379 */380 public function replies_metabox() {381 382 // Bail if post_type is not a reply383 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {384 return;385 }386 387 // Add the meta-box388 add_meta_box(371 ); 372 } 373 374 /** 375 * Add the replies meta-box 376 * 377 * Allows viewing & moderating of replies to a topic, based on the way 378 * comments are visible on a blog post. 379 * 380 * @since 2.6.0 bbPress (r5886) 381 */ 382 public function replies_metabox() { 383 384 // Bail if post_type is not a reply 385 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) { 386 return; 387 } 388 389 // Add the meta-box 390 add_meta_box( 389 391 'bbp_topic_replies_metabox', 390 392 esc_html__( 'Replies', 'bbpress' ), … … 393 395 'normal', 394 396 'high' 395 );396 }397 398 /**399 * Add the engagements meta-box400 *401 * Allows viewing of users who have engaged in a topic.402 *403 * @since 2.6.0 bbPress (r6333)404 */405 public function engagements_metabox() {406 407 // Bail when creating a new topic408 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {409 return;410 }411 412 // Bail if no engagements413 if ( ! bbp_is_engagements_active() ) {414 return;415 }416 417 // Add the meta-box418 add_meta_box(397 ); 398 } 399 400 /** 401 * Add the engagements meta-box 402 * 403 * Allows viewing of users who have engaged in a topic. 404 * 405 * @since 2.6.0 bbPress (r6333) 406 */ 407 public function engagements_metabox() { 408 409 // Bail when creating a new topic 410 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) { 411 return; 412 } 413 414 // Bail if no engagements 415 if ( ! bbp_is_engagements_active() ) { 416 return; 417 } 418 419 // Add the meta-box 420 add_meta_box( 419 421 'bbp_topic_engagements_metabox', 420 422 esc_html__( 'Engagements', 'bbpress' ), … … 423 425 'side', 424 426 'low' 425 );426 }427 428 /**429 * Add the favorites meta-box430 *431 * Allows viewing of users who have favorited a topic.432 *433 * @since 2.6.0 bbPress (r6197)434 */435 public function favorites_metabox() {436 437 // Bail if post_type is not a reply438 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {439 return;440 }441 442 // Bail if no favorites443 if ( ! bbp_is_favorites_active() ) {444 return;445 }446 447 // Add the meta-box448 add_meta_box(427 ); 428 } 429 430 /** 431 * Add the favorites meta-box 432 * 433 * Allows viewing of users who have favorited a topic. 434 * 435 * @since 2.6.0 bbPress (r6197) 436 */ 437 public function favorites_metabox() { 438 439 // Bail if post_type is not a reply 440 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) { 441 return; 442 } 443 444 // Bail if no favorites 445 if ( ! bbp_is_favorites_active() ) { 446 return; 447 } 448 449 // Add the meta-box 450 add_meta_box( 449 451 'bbp_topic_favorites_metabox', 450 452 esc_html__( 'Favorites', 'bbpress' ), … … 453 455 'normal', 454 456 'high' 455 );456 }457 458 /**459 * Add the subscriptions meta-box460 *461 * Allows viewing of users who have subscribed to a topic.462 *463 * @since 2.6.0 bbPress (r6197)464 */465 public function subscriptions_metabox() {466 467 // Bail if post_type is not a reply468 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) {469 return;470 }471 472 // Bail if no subscriptions473 if ( ! bbp_is_subscriptions_active() ) {474 return;475 }476 477 // Add the meta-box478 add_meta_box(457 ); 458 } 459 460 /** 461 * Add the subscriptions meta-box 462 * 463 * Allows viewing of users who have subscribed to a topic. 464 * 465 * @since 2.6.0 bbPress (r6197) 466 */ 467 public function subscriptions_metabox() { 468 469 // Bail if post_type is not a reply 470 if ( empty( $_GET['action'] ) || ( 'edit' !== $_GET['action'] ) ) { 471 return; 472 } 473 474 // Bail if no subscriptions 475 if ( ! bbp_is_subscriptions_active() ) { 476 return; 477 } 478 479 // Add the meta-box 480 add_meta_box( 479 481 'bbp_topic_subscriptions_metabox', 480 482 esc_html__( 'Subscriptions', 'bbpress' ), … … 483 485 'normal', 484 486 'high' 485 ); 486 } 487 488 /** 489 * Remove comments & discussion meta-boxes if comments are not supported 490 * 491 * @since 2.6.0 bbPress (r6186) 492 */ 493 public function comments_metabox() { 494 if ( ! post_type_supports( $this->post_type, 'comments' ) ) { 495 remove_meta_box( 'commentstatusdiv', $this->post_type, 'normal' ); 496 remove_meta_box( 'commentsdiv', $this->post_type, 'normal' ); 497 } 498 } 499 500 /** 501 * Pass the topic attributes for processing 502 * 503 * @since 2.0.0 bbPress (r2746) 504 * 505 * @param int $topic_id Topic id 506 * @return int Parent id 507 */ 508 public function save_meta_boxes( $topic_id ) { 509 510 // Bail if doing an autosave 511 if ( bbp_doing_autosave() ) { 512 return $topic_id; 513 } 514 515 // Bail if not a post request 516 if ( ! bbp_is_post_request() ) { 517 return $topic_id; 518 } 519 520 // Check action exists 521 if ( empty( $_POST['action'] ) ) { 522 return $topic_id; 523 } 524 525 // Nonce check 526 if ( empty( $_POST['bbp_topic_metabox'] ) || ! wp_verify_nonce( $_POST['bbp_topic_metabox'], 'bbp_topic_metabox_save' ) ) { 527 return $topic_id; 528 } 529 530 // Bail if current user cannot edit this topic 531 if ( ! current_user_can( 'edit_topic', $topic_id ) ) { 532 return $topic_id; 533 } 534 535 // Get the forum ID 536 $forum_id = ! empty( $_POST['parent_id'] ) ? (int) $_POST['parent_id'] : 0; 537 538 // Get topic author data 539 $anonymous_data = bbp_filter_anonymous_post_data(); 540 $author_id = bbp_get_topic_author_id( $topic_id ); 541 $is_edit = ( isset( $_POST['hidden_post_status'] ) && ( 'draft' !== $_POST['hidden_post_status'] ) ); 542 543 // Formally update the topic 544 bbp_update_topic( $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit ); 545 546 // Allow other fun things to happen 547 do_action( 'bbp_topic_attributes_metabox_save', $topic_id, $forum_id ); 548 do_action( 'bbp_author_metabox_save', $topic_id, $anonymous_data ); 549 487 ); 488 } 489 490 /** 491 * Remove comments & discussion meta-boxes if comments are not supported 492 * 493 * @since 2.6.0 bbPress (r6186) 494 */ 495 public function comments_metabox() { 496 if ( ! post_type_supports( $this->post_type, 'comments' ) ) { 497 remove_meta_box( 'commentstatusdiv', $this->post_type, 'normal' ); 498 remove_meta_box( 'commentsdiv', $this->post_type, 'normal' ); 499 } 500 } 501 502 /** 503 * Pass the topic attributes for processing 504 * 505 * @since 2.0.0 bbPress (r2746) 506 * 507 * @param int $topic_id Topic id 508 * @return int Parent id 509 */ 510 public function save_meta_boxes( $topic_id ) { 511 512 // Bail if doing an autosave 513 if ( bbp_doing_autosave() ) { 550 514 return $topic_id; 551 } 552 553 /** 554 * Toggle topic 555 * 556 * Handles the admin-side opening/closing, sticking/unsticking and 557 * spamming/unspamming of topics 558 * 559 * @since 2.0.0 bbPress (r2727) 560 */ 561 public function toggle_topic() { 562 563 // Bail if not a topic toggle action 564 if ( ! bbp_is_get_request() || empty( $_GET['action'] ) || empty( $_GET['topic_id'] ) ) { 565 return; 566 } 567 568 // Bail if not an allowed action 569 $action = sanitize_key( $_GET['action'] ); 570 if ( empty( $action ) || ! in_array( $action, $this->get_allowed_action_toggles(), true ) ) { 571 return; 572 } 573 574 // Bail if topic is missing 575 $topic_id = bbp_get_topic_id( $_GET['topic_id'] ); 576 if ( ! bbp_get_topic( $topic_id ) ) { 577 wp_die( esc_html__( 'The topic was not found.', 'bbpress' ) ); 578 } 579 580 // What is the user doing here? 581 if ( ! current_user_can( 'moderate', $topic_id ) ) { 582 wp_die( esc_html__( 'You do not have permission to do that.', 'bbpress' ) ); 583 } 584 585 // Defaults 586 $post_data = array( 'ID' => $topic_id ); 587 $message = ''; 588 $success = false; 589 590 switch ( $action ) { 591 case 'bbp_toggle_topic_approve' : 592 check_admin_referer( 'approve-topic_' . $topic_id ); 593 594 $is_approve = bbp_is_topic_public( $topic_id ); 595 $message = ( true === $is_approve ) 515 } 516 517 // Bail if not a post request 518 if ( ! bbp_is_post_request() ) { 519 return $topic_id; 520 } 521 522 // Check action exists 523 if ( empty( $_POST['action'] ) ) { 524 return $topic_id; 525 } 526 527 // Nonce check 528 if ( empty( $_POST['bbp_topic_metabox'] ) || ! wp_verify_nonce( $_POST['bbp_topic_metabox'], 'bbp_topic_metabox_save' ) ) { 529 return $topic_id; 530 } 531 532 // Bail if current user cannot edit this topic 533 if ( ! current_user_can( 'edit_topic', $topic_id ) ) { 534 return $topic_id; 535 } 536 537 // Get the forum ID 538 $forum_id = ! empty( $_POST['parent_id'] ) ? (int) $_POST['parent_id'] : 0; 539 540 // Get topic author data 541 $anonymous_data = bbp_filter_anonymous_post_data(); 542 $author_id = bbp_get_topic_author_id( $topic_id ); 543 $is_edit = ( isset( $_POST['hidden_post_status'] ) && ( 'draft' !== $_POST['hidden_post_status'] ) ); 544 545 // Formally update the topic 546 bbp_update_topic( $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit ); 547 548 // Allow other fun things to happen 549 do_action( 'bbp_topic_attributes_metabox_save', $topic_id, $forum_id ); 550 do_action( 'bbp_author_metabox_save', $topic_id, $anonymous_data ); 551 552 return $topic_id; 553 } 554 555 /** 556 * Toggle topic 557 * 558 * Handles the admin-side opening/closing, sticking/unsticking and 559 * spamming/unspamming of topics 560 * 561 * @since 2.0.0 bbPress (r2727) 562 */ 563 public function toggle_topic() { 564 565 // Bail if not a topic toggle action 566 if ( ! bbp_is_get_request() || empty( $_GET['action'] ) || empty( $_GET['topic_id'] ) ) { 567 return; 568 } 569 570 // Bail if not an allowed action 571 $action = sanitize_key( $_GET['action'] ); 572 if ( empty( $action ) || ! in_array( $action, $this->get_allowed_action_toggles(), true ) ) { 573 return; 574 } 575 576 // Bail if topic is missing 577 $topic_id = bbp_get_topic_id( $_GET['topic_id'] ); 578 if ( ! bbp_get_topic( $topic_id ) ) { 579 wp_die( esc_html__( 'The topic was not found.', 'bbpress' ) ); 580 } 581 582 // What is the user doing here? 583 if ( ! current_user_can( 'moderate', $topic_id ) ) { 584 wp_die( esc_html__( 'You do not have permission to do that.', 'bbpress' ) ); 585 } 586 587 // Defaults 588 $post_data = array( 'ID' => $topic_id ); 589 $message = ''; 590 $success = false; 591 592 switch ( $action ) { 593 case 'bbp_toggle_topic_approve' : 594 check_admin_referer( 'approve-topic_' . $topic_id ); 595 596 $is_approve = bbp_is_topic_public( $topic_id ); 597 $message = ( true === $is_approve ) 596 598 ? 'unapproved' 597 599 : 'approved'; 598 $success = ( true === $is_approve )600 $success = ( true === $is_approve ) 599 601 ? bbp_unapprove_topic( $topic_id ) 600 602 : bbp_approve_topic( $topic_id ); 601 603 602 break;603 604 case 'bbp_toggle_topic_close' :605 check_admin_referer( 'close-topic_' . $topic_id );606 607 $is_open = bbp_is_topic_open( $topic_id );608 $message = ( true === $is_open )604 break; 605 606 case 'bbp_toggle_topic_close' : 607 check_admin_referer( 'close-topic_' . $topic_id ); 608 609 $is_open = bbp_is_topic_open( $topic_id ); 610 $message = ( true === $is_open ) 609 611 ? 'closed' 610 612 : 'opened'; 611 $success = ( true === $is_open )613 $success = ( true === $is_open ) 612 614 ? bbp_close_topic( $topic_id ) 613 615 : bbp_open_topic( $topic_id ); 614 616 615 break;616 617 case 'bbp_toggle_topic_stick' :618 check_admin_referer( 'stick-topic_' . $topic_id );619 620 $is_sticky = bbp_is_topic_sticky( $topic_id );621 $is_super = ( false === $is_sticky ) && ! empty( $_GET['super'] ) && ( '1' === $_GET['super'] )617 break; 618 619 case 'bbp_toggle_topic_stick' : 620 check_admin_referer( 'stick-topic_' . $topic_id ); 621 622 $is_sticky = bbp_is_topic_sticky( $topic_id ); 623 $is_super = ( false === $is_sticky ) && ! empty( $_GET['super'] ) && ( '1' === $_GET['super'] ) 622 624 ? true 623 625 : false; 624 $message = ( true === $is_sticky )626 $message = ( true === $is_sticky ) 625 627 ? 'unstuck' 626 628 : 'stuck'; 627 $message = ( true === $is_super )629 $message = ( true === $is_super ) 628 630 ? 'super_sticky' 629 631 : $message; 630 $success = ( true === $is_sticky )632 $success = ( true === $is_sticky ) 631 633 ? bbp_unstick_topic( $topic_id ) 632 634 : bbp_stick_topic( $topic_id, $is_super ); 633 635 634 break;635 636 case 'bbp_toggle_topic_spam' :637 check_admin_referer( 'spam-topic_' . $topic_id );638 639 $is_spam = bbp_is_topic_spam( $topic_id );640 $message = ( true === $is_spam )636 break; 637 638 case 'bbp_toggle_topic_spam' : 639 check_admin_referer( 'spam-topic_' . $topic_id ); 640 641 $is_spam = bbp_is_topic_spam( $topic_id ); 642 $message = ( true === $is_spam ) 641 643 ? 'unspammed' 642 644 : 'spammed'; 643 $success = ( true === $is_spam )645 $success = ( true === $is_spam ) 644 646 ? bbp_unspam_topic( $topic_id ) 645 647 : bbp_spam_topic( $topic_id ); 646 648 647 break;648 }649 650 // Setup the message651 $retval = array(649 break; 650 } 651 652 // Setup the message 653 $retval = array( 652 654 'bbp_topic_toggle_notice' => $message, 653 655 'topic_id' => $topic_id 654 ); 655 656 // Prepare for failure 657 if ( ( false === $success ) || is_wp_error( $success ) ) { 658 $retval['failed'] = '1'; 659 } 660 661 // Filter all message args 662 $retval = apply_filters( 'bbp_toggle_topic_action_admin', $retval, $topic_id, $action ); 663 664 // Do additional topic toggle actions (admin side) 665 do_action( 'bbp_toggle_topic_admin', $success, $post_data, $action, $retval ); 666 667 // Redirect back to the topic 668 $redirect = add_query_arg( $retval, remove_query_arg( array( 'action', 'topic_id' ) ) ); 669 bbp_redirect( $redirect ); 670 } 671 672 /** 673 * Toggle topic notices 674 * 675 * Display the success/error notices from 676 * {@link BBP_Admin::toggle_topic()} 677 * 678 * @since 2.0.0 bbPress (r2727) 679 */ 680 public function toggle_topic_notice() { 681 682 // Bail if missing topic toggle action 683 if ( ! bbp_is_get_request() || empty( $_GET['topic_id'] ) || empty( $_GET['bbp_topic_toggle_notice'] ) ) { 684 return; 685 } 686 687 // Bail if not an allowed notice 688 $notice = sanitize_key( $_GET['bbp_topic_toggle_notice'] ); 689 if ( empty( $notice ) || ! in_array( $notice, $this->get_allowed_notice_toggles(), true ) ) { 690 return; 691 } 692 693 // Bail if no topic_id or notice 694 $topic_id = bbp_get_topic_id( $_GET['topic_id'] ); 695 if ( empty( $topic_id ) ) { 696 return; 697 } 698 699 // Bail if topic is missing 700 if ( ! bbp_get_topic( $topic_id ) ) { 701 return; 702 } 703 704 // Use the title in the responses 705 $topic_title = bbp_get_topic_title( $topic_id ); 706 $is_failure = ! empty( $_GET['failed'] ); 707 $message = ''; 708 709 // Which notice? 710 switch ( $notice ) { 711 case 'opened' : 712 $message = ( true === $is_failure ) 656 ); 657 658 // Prepare for failure 659 if ( ( false === $success ) || is_wp_error( $success ) ) { 660 $retval['failed'] = '1'; 661 } 662 663 // Filter all message args 664 $retval = apply_filters( 'bbp_toggle_topic_action_admin', $retval, $topic_id, $action ); 665 666 // Do additional topic toggle actions (admin side) 667 do_action( 'bbp_toggle_topic_admin', $success, $post_data, $action, $retval ); 668 669 // Redirect back to the topic 670 $redirect = add_query_arg( $retval, remove_query_arg( array( 'action', 'topic_id' ) ) ); 671 bbp_redirect( $redirect ); 672 } 673 674 /** 675 * Toggle topic notices 676 * 677 * Display the success/error notices from 678 * {@link BBP_Admin::toggle_topic()} 679 * 680 * @since 2.0.0 bbPress (r2727) 681 */ 682 public function toggle_topic_notice() { 683 684 // Bail if missing topic toggle action 685 if ( ! bbp_is_get_request() || empty( $_GET['topic_id'] ) || empty( $_GET['bbp_topic_toggle_notice'] ) ) { 686 return; 687 } 688 689 // Bail if not an allowed notice 690 $notice = sanitize_key( $_GET['bbp_topic_toggle_notice'] ); 691 if ( empty( $notice ) || ! in_array( $notice, $this->get_allowed_notice_toggles(), true ) ) { 692 return; 693 } 694 695 // Bail if no topic_id or notice 696 $topic_id = bbp_get_topic_id( $_GET['topic_id'] ); 697 if ( empty( $topic_id ) ) { 698 return; 699 } 700 701 // Bail if topic is missing 702 if ( ! bbp_get_topic( $topic_id ) ) { 703 return; 704 } 705 706 // Use the title in the responses 707 $topic_title = bbp_get_topic_title( $topic_id ); 708 $is_failure = ! empty( $_GET['failed'] ); 709 $message = ''; 710 711 // Which notice? 712 switch ( $notice ) { 713 case 'opened' : 714 $message = ( true === $is_failure ) 715 /* translators: %1$s: Topic title */ 713 716 ? sprintf( esc_html__( 'There was a problem opening the topic "%1$s".', 'bbpress' ), $topic_title ) 717 /* translators: %1$s: Topic title */ 714 718 : sprintf( esc_html__( 'Topic "%1$s" successfully opened.', 'bbpress' ), $topic_title ); 715 break; 716 717 case 'closed' : 718 $message = ( true === $is_failure ) 719 break; 720 721 case 'closed' : 722 $message = ( true === $is_failure ) 723 /* translators: %1$s: Topic title */ 719 724 ? sprintf( esc_html__( 'There was a problem closing the topic "%1$s".', 'bbpress' ), $topic_title ) 725 /* translators: %1$s: Topic title */ 720 726 : sprintf( esc_html__( 'Topic "%1$s" successfully closed.', 'bbpress' ), $topic_title ); 721 break; 722 723 case 'super_sticky' : 724 $message = ( true === $is_failure ) 727 break; 728 729 case 'super_sticky' : 730 $message = ( true === $is_failure ) 731 /* translators: %1$s: Topic title */ 725 732 ? sprintf( esc_html__( 'There was a problem sticking the topic "%1$s" to front.', 'bbpress' ), $topic_title ) 733 /* translators: %1$s: Topic title */ 726 734 : sprintf( esc_html__( 'Topic "%1$s" successfully stuck to front.', 'bbpress' ), $topic_title ); 727 break; 728 729 case 'stuck' : 730 $message = ( true === $is_failure ) 735 break; 736 737 case 'stuck' : 738 $message = ( true === $is_failure ) 739 /* translators: %1$s: Topic title */ 731 740 ? sprintf( esc_html__( 'There was a problem sticking the topic "%1$s".', 'bbpress' ), $topic_title ) 741 /* translators: %1$s: Topic title */ 732 742 : sprintf( esc_html__( 'Topic "%1$s" successfully stuck.', 'bbpress' ), $topic_title ); 733 break; 734 735 case 'unstuck' : 736 $message = ( true === $is_failure ) 743 break; 744 745 case 'unstuck' : 746 $message = ( true === $is_failure ) 747 /* translators: %1$s: Topic title */ 737 748 ? sprintf( esc_html__( 'There was a problem unsticking the topic "%1$s".', 'bbpress' ), $topic_title ) 749 /* translators: %1$s: Topic title */ 738 750 : sprintf( esc_html__( 'Topic "%1$s" successfully unstuck.', 'bbpress' ), $topic_title ); 739 break; 740 741 case 'spammed' : 742 $message = ( true === $is_failure ) 751 break; 752 753 case 'spammed' : 754 $message = ( true === $is_failure ) 755 /* translators: %1$s: Topic title */ 743 756 ? sprintf( esc_html__( 'There was a problem marking the topic "%1$s" as spam.', 'bbpress' ), $topic_title ) 757 /* translators: %1$s: Topic title */ 744 758 : sprintf( esc_html__( 'Topic "%1$s" successfully marked as spam.', 'bbpress' ), $topic_title ); 745 break; 746 747 case 'unspammed' : 748 $message = ( true === $is_failure ) 759 break; 760 761 case 'unspammed' : 762 $message = ( true === $is_failure ) 763 /* translators: %1$s: Topic title */ 749 764 ? sprintf( esc_html__( 'There was a problem unmarking the topic "%1$s" as spam.', 'bbpress' ), $topic_title ) 765 /* translators: %1$s: Topic title */ 750 766 : sprintf( esc_html__( 'Topic "%1$s" successfully unmarked as spam.', 'bbpress' ), $topic_title ); 751 break; 752 753 case 'approved' : 754 $message = ( true === $is_failure ) 767 break; 768 769 case 'approved' : 770 $message = ( true === $is_failure ) 771 /* translators: %1$s: Topic title */ 755 772 ? sprintf( esc_html__( 'There was a problem approving the topic "%1$s".', 'bbpress' ), $topic_title ) 773 /* translators: %1$s: Topic title */ 756 774 : sprintf( esc_html__( 'Topic "%1$s" successfully approved.', 'bbpress' ), $topic_title ); 757 break; 758 759 case 'unapproved' : 760 $message = ( true === $is_failure ) 775 break; 776 777 case 'unapproved' : 778 $message = ( true === $is_failure ) 779 /* translators: %1$s: Topic title */ 761 780 ? sprintf( esc_html__( 'There was a problem unapproving the topic "%1$s".', 'bbpress' ), $topic_title ) 781 /* translators: %1$s: Topic title */ 762 782 : sprintf( esc_html__( 'Topic "%1$s" successfully unapproved.', 'bbpress' ), $topic_title ); 763 break;764 }765 766 // Do additional topic toggle notice filters (admin side)767 $message = apply_filters( 'bbp_toggle_topic_notice_admin', $message, $topic_id, $notice, $is_failure );768 $class = ( true === $is_failure )783 break; 784 } 785 786 // Do additional topic toggle notice filters (admin side) 787 $message = apply_filters( 'bbp_toggle_topic_notice_admin', $message, $topic_id, $notice, $is_failure ); 788 $class = ( true === $is_failure ) 769 789 ? 'error' 770 790 : 'updated'; 771 791 772 // Add the notice773 bbp_admin()->add_notice( $message, $class, true );774 }775 776 /**777 * Returns an array of keys used to sort row actions778 *779 * @since 2.6.0 bbPress (r6771)780 *781 * @return array782 */783 private function get_row_action_sort_order() {784 785 // Filter & return786 return (array) apply_filters( 'bbp_admin_topics_row_action_sort_order', array(792 // Add the notice 793 bbp_admin()->add_notice( $message, $class, true ); 794 } 795 796 /** 797 * Returns an array of keys used to sort row actions 798 * 799 * @since 2.6.0 bbPress (r6771) 800 * 801 * @return array 802 */ 803 private function get_row_action_sort_order() { 804 805 // Filter & return 806 return (array) apply_filters( 'bbp_admin_topics_row_action_sort_order', array( 787 807 'edit', 788 808 'stick', … … 796 816 'delete', 797 817 'view' 798 ) );799 }800 801 /**802 * Returns an array of notice toggles803 *804 * @since 2.6.0 bbPress (r6396)805 *806 * @return array807 */808 private function get_allowed_notice_toggles() {809 810 // Filter & return811 return (array) apply_filters( 'bbp_admin_topics_allowed_notice_toggles', array(818 ) ); 819 } 820 821 /** 822 * Returns an array of notice toggles 823 * 824 * @since 2.6.0 bbPress (r6396) 825 * 826 * @return array 827 */ 828 private function get_allowed_notice_toggles() { 829 830 // Filter & return 831 return (array) apply_filters( 'bbp_admin_topics_allowed_notice_toggles', array( 812 832 'opened', 813 833 'closed', … … 819 839 'approved', 820 840 'unapproved' 821 ) );822 }823 824 /**825 * Returns an array of notice toggles826 *827 * @since 2.6.0 bbPress (r6396)828 *829 * @return array830 */831 private function get_allowed_action_toggles() {832 833 // Filter & return834 return (array) apply_filters( 'bbp_admin_topics_allowed_action_toggles', array(841 ) ); 842 } 843 844 /** 845 * Returns an array of notice toggles 846 * 847 * @since 2.6.0 bbPress (r6396) 848 * 849 * @return array 850 */ 851 private function get_allowed_action_toggles() { 852 853 // Filter & return 854 return (array) apply_filters( 'bbp_admin_topics_allowed_action_toggles', array( 835 855 'bbp_toggle_topic_close', 836 856 'bbp_toggle_topic_stick', 837 857 'bbp_toggle_topic_spam', 838 858 'bbp_toggle_topic_approve' 839 ) );840 }841 842 /**843 * Manage the column headers for the topics page844 *845 * @since 2.0.0 bbPress (r2485)846 *847 * @param array $columns The columns848 *849 * @return array $columns bbPress topic columns850 */851 public function column_headers( $columns ) {852 $columns = array(859 ) ); 860 } 861 862 /** 863 * Manage the column headers for the topics page 864 * 865 * @since 2.0.0 bbPress (r2485) 866 * 867 * @param array $columns The columns 868 * 869 * @return array $columns bbPress topic columns 870 */ 871 public function column_headers( $columns ) { 872 $columns = array( 853 873 'cb' => '<input type="checkbox" />', 854 874 'title' => esc_html__( 'Topics', 'bbpress' ), … … 859 879 'bbp_topic_created' => esc_html__( 'Created', 'bbpress' ), 860 880 'bbp_topic_freshness' => esc_html__( 'Last Post', 'bbpress' ) 861 );862 863 // Filter & return864 return (array) apply_filters( 'bbp_admin_topics_column_headers', $columns );865 }866 867 /**868 * Print extra columns for the topics page869 *870 * @since 2.0.0 bbPress (r2485)871 *872 * @param string $column Column873 * @param int $topic_id Topic id874 */875 public function column_data( $column, $topic_id ) {876 877 // Get topic forum ID878 $forum_id = bbp_get_topic_forum_id( $topic_id );879 880 // Populate column data881 switch ( $column ) {882 883 // Forum884 case 'bbp_topic_forum' :885 886 // Get title887 $forum_title = ! empty( $forum_id )881 ); 882 883 // Filter & return 884 return (array) apply_filters( 'bbp_admin_topics_column_headers', $columns ); 885 } 886 887 /** 888 * Print extra columns for the topics page 889 * 890 * @since 2.0.0 bbPress (r2485) 891 * 892 * @param string $column Column 893 * @param int $topic_id Topic id 894 */ 895 public function column_data( $column, $topic_id ) { 896 897 // Get topic forum ID 898 $forum_id = bbp_get_topic_forum_id( $topic_id ); 899 900 // Populate column data 901 switch ( $column ) { 902 903 // Forum 904 case 'bbp_topic_forum' : 905 906 // Get title 907 $forum_title = ! empty( $forum_id ) 888 908 ? bbp_get_forum_title( $forum_id ) 889 909 : ''; 890 910 891 // Output forum name892 if ( ! empty( $forum_title ) ) {893 echo $forum_title;894 895 // Output dash896 } else {897 ?>911 // Output forum name 912 if ( ! empty( $forum_title ) ) { 913 echo $forum_title; 914 915 // Output dash 916 } else { 917 ?> 898 918 <span aria-hidden="true">—</span> 899 919 <span class="screen-reader-text"><?php esc_html_e( 'No forum', 'bbpress' ); ?></span> 900 920 <?php 901 }902 903 break;904 905 // Reply Count906 case 'bbp_topic_reply_count' :907 bbp_topic_reply_count( $topic_id );908 break;909 910 // Reply Count911 case 'bbp_topic_voice_count' :912 bbp_topic_voice_count( $topic_id );913 break;914 915 // Author916 case 'bbp_topic_author' :917 bbp_topic_author_display_name( $topic_id );918 break;919 920 // Freshness921 case 'bbp_topic_created':922 printf( '%1$s <br /> %2$s',921 } 922 923 break; 924 925 // Reply Count 926 case 'bbp_topic_reply_count' : 927 bbp_topic_reply_count( $topic_id ); 928 break; 929 930 // Reply Count 931 case 'bbp_topic_voice_count' : 932 bbp_topic_voice_count( $topic_id ); 933 break; 934 935 // Author 936 case 'bbp_topic_author' : 937 bbp_topic_author_display_name( $topic_id ); 938 break; 939 940 // Freshness 941 case 'bbp_topic_created': 942 printf( '%1$s <br /> %2$s', 923 943 get_the_date(), 924 944 esc_attr( get_the_time() ) 925 ); 926 927 break; 928 929 // Freshness 930 case 'bbp_topic_freshness' : 931 $last_active = bbp_get_topic_last_active_time( $topic_id, false ); 932 if ( ! empty( $last_active ) ) { 933 echo esc_html( $last_active ); 934 } else { 935 esc_html_e( 'No Replies', 'bbpress' ); // This should never happen 936 } 937 938 break; 939 940 // Do an action for anything else 941 default : 942 do_action( 'bbp_admin_topics_column_data', $column, $topic_id ); 943 break; 945 ); 946 947 break; 948 949 // Freshness 950 case 'bbp_topic_freshness' : 951 $last_active = bbp_get_topic_last_active_time( $topic_id, false ); 952 if ( ! empty( $last_active ) ) { 953 echo esc_html( $last_active ); 954 } else { 955 esc_html_e( 'No Replies', 'bbpress' ); // This should never happen 956 } 957 958 break; 959 960 // Do an action for anything else 961 default : 962 do_action( 'bbp_admin_topics_column_data', $column, $topic_id ); 963 break; 964 } 965 } 966 967 /** 968 * Topic Row actions 969 * 970 * Remove the quick-edit action link under the topic title and add the 971 * content and close/stick/spam links 972 * 973 * @since 2.0.0 bbPress (r2485) 974 * 975 * @param array $actions Actions 976 * @param object $topic Topic object 977 * 978 * @return array $actions Actions 979 */ 980 public function row_actions( $actions = array(), $topic = false ) { 981 982 // Disable quick edit (too much to do here) 983 unset( $actions['inline hide-if-no-js'] ); 984 985 // View link 986 $view_link = bbp_get_topic_permalink( $topic->ID ); 987 988 // Maybe add view=all 989 if ( ! in_array( $topic->post_status, array( bbp_get_closed_status_id(), bbp_get_public_status_id() ), true ) ) { 990 $view_link = bbp_add_view_all( $view_link, true ); 991 } 992 993 // Show view link if it's not set, the topic is trashed and the user can view trashed topics 994 if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() === $topic->post_status ) && current_user_can( 'view_trash' ) ) { 995 /* translators: %s: Topic title */ 996 $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 997 } 998 999 // Only show the actions if the user is capable of viewing them :) 1000 if ( current_user_can( 'moderate', $topic->ID ) ) { 1001 1002 // Pending 1003 // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only 1004 $approve_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'approve-topic_' . $topic->ID ); 1005 if ( bbp_is_topic_public( $topic->ID ) ) { 1006 $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this topic', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove Topic', 'bbpress' ) . '</a>'; 1007 } else { 1008 1009 // Do not show 'approve' if already public 1010 if ( ! bbp_is_topic_public( $topic->ID ) ) { 1011 $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic', 'bbpress' ) . '">' . _x( 'Approve', 'Approve Topic', 'bbpress' ) . '</a>'; 1012 } 1013 1014 // Modify the view link 1015 /* translators: %s: Topic title */ 1016 $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 944 1017 } 945 } 946 947 /** 948 * Topic Row actions 949 * 950 * Remove the quick-edit action link under the topic title and add the 951 * content and close/stick/spam links 952 * 953 * @since 2.0.0 bbPress (r2485) 954 * 955 * @param array $actions Actions 956 * @param object $topic Topic object 957 * 958 * @return array $actions Actions 959 */ 960 public function row_actions( $actions = array(), $topic = false ) { 961 962 // Disable quick edit (too much to do here) 963 unset( $actions['inline hide-if-no-js'] ); 964 965 // View link 966 $view_link = bbp_get_topic_permalink( $topic->ID ); 967 968 // Maybe add view=all 969 if ( ! in_array( $topic->post_status, array( bbp_get_closed_status_id(), bbp_get_public_status_id() ), true ) ) { 970 $view_link = bbp_add_view_all( $view_link, true ); 971 } 972 973 // Show view link if it's not set, the topic is trashed and the user can view trashed topics 974 if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() === $topic->post_status ) && current_user_can( 'view_trash' ) ) { 975 $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 976 } 977 978 // Only show the actions if the user is capable of viewing them :) 979 if ( current_user_can( 'moderate', $topic->ID ) ) { 980 981 // Pending 982 // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only 983 $approve_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'approve-topic_' . $topic->ID ); 984 if ( bbp_is_topic_public( $topic->ID ) ) { 985 $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this topic', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove Topic', 'bbpress' ) . '</a>'; 1018 1019 // Close 1020 // Show the 'close' and 'open' link on published and closed posts only 1021 if ( bbp_is_topic_public( $topic->ID ) ) { 1022 $close_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'close-topic_' . $topic->ID ); 1023 if ( bbp_is_topic_open( $topic->ID ) ) { 1024 $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Close this topic', 'bbpress' ) . '">' . _x( 'Close', 'Close a Topic', 'bbpress' ) . '</a>'; 986 1025 } else { 987 988 // Do not show 'approve' if already public 989 if ( ! bbp_is_topic_public( $topic->ID ) ) { 990 $actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic', 'bbpress' ) . '">' . _x( 'Approve', 'Approve Topic', 'bbpress' ) . '</a>'; 991 } 992 993 // Modify the view link 994 $actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>'; 995 } 996 997 // Close 998 // Show the 'close' and 'open' link on published and closed posts only 999 if ( bbp_is_topic_public( $topic->ID ) ) { 1000 $close_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'close-topic_' . $topic->ID ); 1001 if ( bbp_is_topic_open( $topic->ID ) ) { 1002 $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Close this topic', 'bbpress' ) . '">' . _x( 'Close', 'Close a Topic', 'bbpress' ) . '</a>'; 1003 } else { 1004 $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Open this topic', 'bbpress' ) . '">' . _x( 'Open', 'Open a Topic', 'bbpress' ) . '</a>'; 1005 } 1006 } 1007 1008 // Sticky 1009 // Dont show sticky if topic is spam, trash or pending 1010 if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) { 1011 $stick_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_' . $topic->ID ); 1012 if ( bbp_is_topic_sticky( $topic->ID ) ) { 1013 $actions['stick'] = '<a href="' . esc_url( $stick_uri ) . '" title="' . esc_attr__( 'Unstick this topic', 'bbpress' ) . '">' . esc_html__( 'Unstick', 'bbpress' ) . '</a>'; 1014 } else { 1015 $super_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_' . $topic->ID ); 1016 $actions['stick'] = '<a href="' . esc_url( $stick_uri ) . '" title="' . esc_attr__( 'Stick this topic to its forum', 'bbpress' ) . '">' . esc_html__( 'Stick', 'bbpress' ) . '</a> <a href="' . esc_url( $super_uri ) . '" title="' . esc_attr__( 'Stick this topic to front', 'bbpress' ) . '">' . esc_html__( '(to front)', 'bbpress' ) . '</a>'; 1017 } 1018 } 1019 1020 // Spam 1021 $spam_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'spam-topic_' . $topic->ID ); 1022 if ( ! bbp_is_topic_spam( $topic->ID ) ) { 1023 $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this topic as spam', 'bbpress' ) . '">' . esc_html__( 'Spam', 'bbpress' ) . '</a>'; 1024 } else { 1025 $actions['unspam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the topic as not spam', 'bbpress' ) . '">' . esc_html__( 'Not Spam', 'bbpress' ) . '</a>'; 1026 $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Open this topic', 'bbpress' ) . '">' . _x( 'Open', 'Open a Topic', 'bbpress' ) . '</a>'; 1026 1027 } 1027 1028 } 1028 1029 1029 // Do not show trash links for spam topics, or spam links for trashed topics 1030 if ( current_user_can( 'delete_topic', $topic->ID ) ) { 1031 $trash_days = bbp_get_trash_days( bbp_get_topic_post_type() ); 1032 1033 if ( bbp_get_trash_status_id() === $topic->post_status ) { 1034 $post_type_object = get_post_type_object( bbp_get_topic_post_type() ); 1035 $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . esc_url( wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $topic->ID ) ), 'untrash-post_' . $topic->ID ) ) . "'>" . esc_html__( 'Restore', 'bbpress' ) . '</a>'; 1036 } elseif ( ! empty( $trash_days ) ) { 1037 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $topic->ID ) ) . "'>" . esc_html__( 'Trash', 'bbpress' ) . '</a>'; 1038 } 1039 1040 if ( ( bbp_get_trash_status_id() === $topic->post_status ) || empty( $trash_days ) ) { 1041 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $topic->ID, '', true ) ) . "'>" . esc_html__( 'Delete Permanently', 'bbpress' ) . '</a>'; 1030 // Sticky 1031 // Dont show sticky if topic is spam, trash or pending 1032 if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) { 1033 $stick_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_' . $topic->ID ); 1034 if ( bbp_is_topic_sticky( $topic->ID ) ) { 1035 $actions['stick'] = '<a href="' . esc_url( $stick_uri ) . '" title="' . esc_attr__( 'Unstick this topic', 'bbpress' ) . '">' . esc_html__( 'Unstick', 'bbpress' ) . '</a>'; 1036 } else { 1037 $super_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_' . $topic->ID ); 1038 $actions['stick'] = '<a href="' . esc_url( $stick_uri ) . '" title="' . esc_attr__( 'Stick this topic to its forum', 'bbpress' ) . '">' . esc_html__( 'Stick', 'bbpress' ) . '</a> <a href="' . esc_url( $super_uri ) . '" title="' . esc_attr__( 'Stick this topic to front', 'bbpress' ) . '">' . esc_html__( '(to front)', 'bbpress' ) . '</a>'; 1042 1039 } 1043 1040 } 1044 1041 1045 // Sort & return 1046 return $this->sort_row_actions( $actions ); 1042 // Spam 1043 $spam_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'spam-topic_' . $topic->ID ); 1044 if ( ! bbp_is_topic_spam( $topic->ID ) ) { 1045 $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this topic as spam', 'bbpress' ) . '">' . esc_html__( 'Spam', 'bbpress' ) . '</a>'; 1046 } else { 1047 $actions['unspam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the topic as not spam', 'bbpress' ) . '">' . esc_html__( 'Not Spam', 'bbpress' ) . '</a>'; 1047 1048 } 1048 1049 /** 1050 * Sort row actions by key 1051 * 1052 * @since 2.6.0 1053 * 1054 * @param array $actions 1055 * 1056 * @return array 1057 */ 1058 private function sort_row_actions( $actions = array() ) { 1059 1060 // Return value 1061 $retval = array(); 1062 1063 // Known row actions, in sort order 1064 $known_actions = $this->get_row_action_sort_order(); 1065 1066 // Sort known actions, and keep any unknown ones 1067 foreach ( $known_actions as $key ) { 1068 if ( isset( $actions[ $key ] ) ) { 1069 $retval[ $key ] = $actions[ $key ]; 1070 unset( $actions[ $key ] ); 1071 } 1049 } 1050 1051 // Do not show trash links for spam topics, or spam links for trashed topics 1052 if ( current_user_can( 'delete_topic', $topic->ID ) ) { 1053 $trash_days = bbp_get_trash_days( bbp_get_topic_post_type() ); 1054 1055 if ( bbp_get_trash_status_id() === $topic->post_status ) { 1056 $post_type_object = get_post_type_object( bbp_get_topic_post_type() ); 1057 $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . esc_url( wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $topic->ID ) ), 'untrash-post_' . $topic->ID ) ) . "'>" . esc_html__( 'Restore', 'bbpress' ) . '</a>'; 1058 } elseif ( ! empty( $trash_days ) ) { 1059 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $topic->ID ) ) . "'>" . esc_html__( 'Trash', 'bbpress' ) . '</a>'; 1072 1060 } 1073 1061 1074 // Combine & return1075 return $retval + $actions;1062 if ( ( bbp_get_trash_status_id() === $topic->post_status ) || empty( $trash_days ) ) { 1063 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $topic->ID, '', true ) ) . "'>" . esc_html__( 'Delete Permanently', 'bbpress' ) . '</a>'; 1076 1064 } 1077 1078 /** 1079 * Add forum dropdown to topic and reply list table filters 1080 * 1081 * @since 2.0.0 bbPress (r2991) 1082 * 1083 * @return bool False. If post type is not topic or reply 1084 */ 1085 public function filter_dropdown() { 1086 1087 // Get which forum is selected 1088 $selected = ! empty( $_GET['bbp_forum_id'] ) 1065 } 1066 1067 // Sort & return 1068 return $this->sort_row_actions( $actions ); 1069 } 1070 1071 /** 1072 * Sort row actions by key 1073 * 1074 * @since 2.6.0 1075 * 1076 * @param array $actions 1077 * 1078 * @return array 1079 */ 1080 private function sort_row_actions( $actions = array() ) { 1081 1082 // Return value 1083 $retval = array(); 1084 1085 // Known row actions, in sort order 1086 $known_actions = $this->get_row_action_sort_order(); 1087 1088 // Sort known actions, and keep any unknown ones 1089 foreach ( $known_actions as $key ) { 1090 if ( isset( $actions[ $key ] ) ) { 1091 $retval[ $key ] = $actions[ $key ]; 1092 unset( $actions[ $key ] ); 1093 } 1094 } 1095 1096 // Combine & return 1097 return $retval + $actions; 1098 } 1099 1100 /** 1101 * Add forum dropdown to topic and reply list table filters 1102 * 1103 * @since 2.0.0 bbPress (r2991) 1104 * 1105 * @return bool False. If post type is not topic or reply 1106 */ 1107 public function filter_dropdown() { 1108 1109 // Get which forum is selected 1110 $selected = ! empty( $_GET['bbp_forum_id'] ) 1089 1111 ? (int) $_GET['bbp_forum_id'] 1090 1112 : 0; 1091 1113 1092 // Show the forums dropdown 1093 bbp_dropdown( array( 1094 'selected' => $selected, 1095 'show_none' => esc_html__( 'In all forums', 'bbpress' ) 1096 ) ); 1097 } 1098 1099 /** 1100 * Add "Empty Spam" button for moderators 1101 * 1102 * @since 2.6.0 bbPress (r6791) 1103 */ 1104 public function filter_empty_spam() { 1105 1106 // Bail if not viewing spam 1107 if ( empty( $_GET['post_status'] ) || ( bbp_get_spam_status_id() !== $_GET['post_status'] ) && current_user_can( 'moderate' ) ) { 1108 return; 1109 } 1110 1111 ?> 1114 // Show the forums dropdown 1115 bbp_dropdown( 1116 array( 1117 'selected' => $selected, 1118 'show_none' => esc_html__( 'In all forums', 'bbpress' ) 1119 ) 1120 ); 1121 } 1122 1123 /** 1124 * Add "Empty Spam" button for moderators 1125 * 1126 * @since 2.6.0 bbPress (r6791) 1127 */ 1128 public function filter_empty_spam() { 1129 1130 // Bail if not viewing spam 1131 if ( empty( $_GET['post_status'] ) || ( bbp_get_spam_status_id() !== $_GET['post_status'] ) && current_user_can( 'moderate' ) ) { 1132 return; 1133 } 1134 1135 ?> 1112 1136 1113 1137 <div class="alignleft actions"><?php … … 1120 1144 'delete_all', 1121 1145 false 1122 );1123 1124 ?></div><?php1125 } 1126 1127 /**1128 * Adjust the request query and include the forum id1129 *1130 * @since 2.0.0 bbPress (r2991)1131 *1132 * @param array $query_vars Query variables from {@link WP_Query}1133 * @return array Processed Query Vars1134 */1135 function filter_post_rows( $query_vars ) {1136 1137 // Add post_parent query_var if one is present1138 if ( ! empty( $_GET['bbp_forum_id'] ) ) {1139 $query_vars['meta_key'] = '_bbp_forum_id';1140 $query_vars['meta_type'] = 'NUMERIC';1141 $query_vars['meta_value'] = $_GET['bbp_forum_id'];1142 }1143 1144 // Return manipulated query_vars1145 return $query_vars;1146 }1147 1148 /**1149 * Custom user feedback messages for topic post type1150 *1151 * @since 2.0.0 bbPress (r3080)1152 *1153 * @global int $post_ID1154 *1155 * @param array $messages1156 *1157 * @return array1158 */1159 public function updated_messages( $messages ) {1160 global $post_ID;1161 1162 // URL for the current topic1163 $topic_url = bbp_get_topic_permalink( $post_ID );1164 1165 // Current topic's post_date1166 $post_date = bbp_get_global_post_field( 'post_date', 'raw' );1167 1168 // Messages array1169 $messages[ $this->post_type ] = array(1146 ); 1147 1148 ?></div><?php 1149 } 1150 1151 /** 1152 * Adjust the request query and include the forum id 1153 * 1154 * @since 2.0.0 bbPress (r2991) 1155 * 1156 * @param array $query_vars Query variables from {@link WP_Query} 1157 * @return array Processed Query Vars 1158 */ 1159 function filter_post_rows( $query_vars ) { 1160 1161 // Add post_parent query_var if one is present 1162 if ( ! empty( $_GET['bbp_forum_id'] ) ) { 1163 $query_vars['meta_key'] = '_bbp_forum_id'; 1164 $query_vars['meta_type'] = 'NUMERIC'; 1165 $query_vars['meta_value'] = $_GET['bbp_forum_id']; 1166 } 1167 1168 // Return manipulated query_vars 1169 return $query_vars; 1170 } 1171 1172 /** 1173 * Custom user feedback messages for topic post type 1174 * 1175 * @since 2.0.0 bbPress (r3080) 1176 * 1177 * @global int $post_ID 1178 * 1179 * @param array $messages 1180 * 1181 * @return array 1182 */ 1183 public function updated_messages( $messages ) { 1184 global $post_ID; 1185 1186 // URL for the current topic 1187 $topic_url = bbp_get_topic_permalink( $post_ID ); 1188 1189 // Current topic's post_date 1190 $post_date = bbp_get_global_post_field( 'post_date', 'raw' ); 1191 1192 // Messages array 1193 $messages[ $this->post_type ] = array( 1170 1194 0 => '', // Left empty on purpose 1171 1195 … … 1188 1212 1189 1213 // Restored from revision 1190 / / translators: %s: date and time of the revision1214 /* translators: %s: date and time of the revision */ 1191 1215 5 => isset( $_GET['revision'] ) 1216 /* translators: %s: Date and time of the revision */ 1192 1217 ? sprintf( esc_html__( 'Topic restored to revision from %s', 'bbpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) 1193 1218 : false, … … 1216 1241 '%1$s <a target="_blank" href="%2$s">%3$s</a>', 1217 1242 sprintf( 1243 /* translators: Publish box date format, see http://php.net/date */ 1218 1244 esc_html__( 'Topic scheduled for: %s.', 'bbpress' ), 1219 // translators: Publish box date format, see http://php.net/date1220 1245 '<strong>' . date_i18n( __( 'M j, Y @ G:i', 'bbpress' ), strtotime( $post_date ) ) . '</strong>' 1221 1246 ), … … 1231 1256 esc_html__( 'Preview topic', 'bbpress' ) 1232 1257 ), 1233 );1234 1235 return $messages;1236 }1258 ); 1259 1260 return $messages; 1261 } 1237 1262 } 1238 1263 endif; // class_exists check -
trunk/src/includes/common/classes.php
r7357 r7360 491 491 // Determine reply title (either post_title, or excerpt of post_content) 492 492 $title = ! empty( $object->post_title ) ? $object->post_title : wp_html_excerpt( $object->post_content, 10 ); 493 /* translators: 1: Reply ID, 2: Reply title */ 493 494 $title = sprintf( esc_html__( '%1$s - %2$s', 'bbpress' ), (int) $object->ID, $title ); 494 495 $title = apply_filters( 'bbp_walker_dropdown_post_title', $title, $output, $object, $depth, $args ); -
trunk/src/includes/common/formatting.php
r7359 r7360 646 646 $unknown_text = apply_filters( 'bbp_core_time_since_unknown_text', esc_html__( 'sometime', 'bbpress' ) ); 647 647 $right_now_text = apply_filters( 'bbp_core_time_since_right_now_text', esc_html__( 'right now', 'bbpress' ) ); 648 /* translators: %s: Time period */ 648 649 $ago_text = apply_filters( 'bbp_core_time_since_ago_text', esc_html__( '%s ago', 'bbpress' ) ); 649 650 650 651 // array of time period chunks 651 652 $chunks = array( 653 /* translators: %s: Number of years */ 652 654 array( YEAR_IN_SECONDS, _n_noop( '%s year', '%s years', 'bbpress' ) ), 655 /* translators: %s: Number of months */ 653 656 array( MONTH_IN_SECONDS, _n_noop( '%s month', '%s months', 'bbpress' ) ), 657 /* translators: %s: Number of weeks */ 654 658 array( WEEK_IN_SECONDS, _n_noop( '%s week', '%s weeks', 'bbpress' ) ), 659 /* translators: %s: Number of days */ 655 660 array( DAY_IN_SECONDS, _n_noop( '%s day', '%s days', 'bbpress' ) ), 661 /* translators: %s: Number of hours */ 656 662 array( HOUR_IN_SECONDS, _n_noop( '%s hour', '%s hours', 'bbpress' ) ), 663 /* translators: %s: Number of minutes */ 657 664 array( MINUTE_IN_SECONDS, _n_noop( '%s minute', '%s minutes', 'bbpress' ) ), 665 /* translators: %s: Number of seconds */ 658 666 array( 1, _n_noop( '%s second', '%s seconds', 'bbpress' ) ), 659 667 ); -
trunk/src/includes/common/functions.php
r7357 r7360 386 386 387 387 // Defaults 388 $topic_count = $topic_count_hidden = 0;389 $reply_count = $reply_count_hidden = 0;390 $topic_tag_count = $empty_topic_tag_count = 0;391 $hidden_topic_title = $hidden_reply_title = '';388 $topic_count = $topic_count_hidden = 0; 389 $reply_count = $reply_count_hidden = 0; 390 $topic_tag_count = $empty_topic_tag_count = 0; 391 $hidden_topic_title = $hidden_reply_title = ''; 392 392 393 393 // Post statuses … … 440 440 if ( ! empty( $r['count_pending_topics'] ) && ! empty( $caps['edit_others_topics'] ) ) { 441 441 $topics[ $pending ] = bbp_number_not_negative( $all_topics->{$pending} ); 442 /* translators: %s: Number of pending topics */ 442 443 $topic_titles[ $pending ] = sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $pending ] ) ); 443 444 } … … 446 447 if ( ! empty( $r['count_private_topics'] ) && ! empty( $caps['read_private_topics'] ) ) { 447 448 $topics[ $private ] = bbp_number_not_negative( $all_topics->{$private} ); 449 /* translators: %s: Number of private topics */ 448 450 $topic_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $private ] ) ); 449 451 } … … 452 454 if ( ! empty( $r['count_hidden_topics'] ) && ! empty( $caps['read_hidden_topics'] ) ) { 453 455 $topics[ $hidden ] = bbp_number_not_negative( $all_topics->{$hidden} ); 456 /* translators: %s: Number of hidden topics */ 454 457 $topic_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $hidden ] ) ); 455 458 } … … 458 461 if ( ! empty( $r['count_spam_topics'] ) && ! empty( $caps['edit_others_topics'] ) ) { 459 462 $topics[ $spam ] = bbp_number_not_negative( $all_topics->{$spam} ); 463 /* translators: %s: Number of spam topics */ 460 464 $topic_titles[ $spam ] = sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $spam ] ) ); 461 465 } … … 464 468 if ( ! empty( $r['count_trash_topics'] ) && ! empty( $caps['view_trash'] ) ) { 465 469 $topics[ $trash ] = bbp_number_not_negative( $all_topics->{$trash} ); 470 /* translators: %s: Number of trashed topics */ 466 471 $topic_titles[ $trash ] = sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $trash ] ) ); 467 472 } … … 489 494 if ( ! empty( $r['count_pending_replies'] ) && ! empty( $caps['edit_others_replies'] ) ) { 490 495 $replies[ $pending ] = bbp_number_not_negative( $all_replies->{$pending} ); 496 /* translators: %s: Number of pending replies */ 491 497 $reply_titles[ $pending ] = sprintf( esc_html__( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $pending ] ) ); 492 498 } … … 495 501 if ( ! empty( $r['count_private_replies'] ) && ! empty( $caps['read_private_replies'] ) ) { 496 502 $replies[ $private ] = bbp_number_not_negative( $all_replies->{$private} ); 503 /* translators: %s: Number of private replies */ 497 504 $reply_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $private ] ) ); 498 505 } … … 501 508 if ( ! empty( $r['count_hidden_replies'] ) && ! empty( $caps['read_hidden_replies'] ) ) { 502 509 $replies[ $hidden ] = bbp_number_not_negative( $all_replies->{$hidden} ); 510 /* translators: %s: Number of hidden replies */ 503 511 $reply_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $hidden ] ) ); 504 512 } … … 507 515 if ( ! empty( $r['count_spam_replies'] ) && ! empty( $caps['edit_others_replies'] ) ) { 508 516 $replies[ $spam ] = bbp_number_not_negative( $all_replies->{$spam} ); 517 /* translators: %s: Number of spam replies */ 509 518 $reply_titles[ $spam ] = sprintf( esc_html__( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $spam ] ) ); 510 519 } … … 513 522 if ( ! empty( $r['count_trash_replies'] ) && ! empty( $caps['view_trash'] ) ) { 514 523 $replies[ $trash ] = bbp_number_not_negative( $all_replies->{$trash} ); 524 /* translators: %s: Number of trashed replies */ 515 525 $reply_titles[ $trash ] = sprintf( esc_html__( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $trash ] ) ); 516 526 } … … 742 752 743 753 // Get the meta SQL 744 $clauses = get_meta_sql( 745 array( 754 $clauses = get_meta_sql( 755 array( 746 756 array( 747 757 'key' => '_bbp_anonymous_email', 748 758 'value' => $email, 749 ) 750 ), 751 'post', 752 $bbp_db->posts, 753 'ID' 759 ) 760 ), 761 'post', 762 $bbp_db->posts, 763 'ID' 754 764 ); 755 765 … … 1154 1164 1155 1165 // For plugins to filter messages per reply/topic/user 1166 /* translators: 1: Reply author name, 2: Reply content, 3: Reply URL */ 1156 1167 $message = sprintf( esc_html__( '%1$s wrote: 1157 1168 … … 1321 1332 1322 1333 // For plugins to filter messages per reply/topic/user 1334 /* translators: 1: Topic author name, 2: Topic content, 3: Topic URL */ 1323 1335 $message = sprintf( esc_html__( '%1$s wrote: 1324 1336 … … 2394 2406 2395 2407 // Restrict to specific forum ID 2396 $meta_query = array( 2408 $meta_query = array( 2397 2409 array( 2398 2410 'key' => '_bbp_forum_id', … … 2400 2412 'type' => 'NUMERIC', 2401 2413 'compare' => '=' 2402 ) 2414 ) 2403 2415 ); 2404 2416 } -
trunk/src/includes/common/template.php
r7352 r7360 2 2 3 3 /** 4 * bbPress Common Template Tags 4 * bbPress Common Template Tags. 5 5 * 6 6 * Common template tags are ones that are used by more than one component, like 7 7 * forums, topics, replies, users, topic tags, etc... 8 *9 * @package bbPress10 * @subpackage TemplateTags11 8 */ 12 9 … … 17 14 18 15 /** 19 * Output the forum URL 16 * Output the forum URL. 20 17 * 21 18 * @since 2.1.0 bbPress (r3979) … … 26 23 echo esc_url( bbp_get_forums_url( $path ) ); 27 24 } 28 /** 29 * Return the forum URL 30 * 31 * @since 2.1.0 bbPress (r3979) 32 * 33 * @param string $path Additional path with leading slash 34 */ 35 function bbp_get_forums_url( $path = '/' ) { 36 return home_url( bbp_get_root_slug() . $path ); 37 } 38 39 /** 40 * Output the forum URL 25 26 /** 27 * Return the forum URL. 28 * 29 * @since 2.1.0 bbPress (r3979) 30 * 31 * @param string $path Additional path with leading slash 32 */ 33 function bbp_get_forums_url( $path = '/' ) { 34 return home_url( bbp_get_root_slug() . $path ); 35 } 36 37 /** 38 * Output the forum URL. 41 39 * 42 40 * @since 2.1.0 bbPress (r3979) … … 47 45 echo esc_url( bbp_get_topics_url( $path ) ); 48 46 } 49 /** 50 * Return the forum URL 51 * 52 * @since 2.1.0 bbPress (r3979) 53 * 54 * @param string $path Additional path with leading slash 55 * @return The URL to the topics archive 56 */ 57 function bbp_get_topics_url( $path = '/' ) { 58 return home_url( bbp_get_topic_archive_slug() . $path ); 59 } 47 48 /** 49 * Return the forum URL. 50 * 51 * @since 2.1.0 bbPress (r3979) 52 * 53 * @param string $path Additional path with leading slash 54 * 55 * @return The URL to the topics archive 56 */ 57 function bbp_get_topics_url( $path = '/' ) { 58 return home_url( bbp_get_topic_archive_slug() . $path ); 59 } 60 60 61 61 /** Add-on Actions ************************************************************/ 62 62 63 63 /** 64 * Add our custom head action to wp_head 64 * Add our custom head action to wp_head. 65 65 * 66 66 * @since 2.0.0 bbPress (r2464) … … 71 71 72 72 /** 73 * Add our custom footer action to wp_footer 73 * Add our custom footer action to wp_footer. 74 74 * 75 75 * @since 2.0.0 bbPress (r2464) … … 82 82 83 83 /** 84 * Check if current site is public 84 * Check if current site is public. 85 85 * 86 86 * @since 2.0.0 bbPress (r3398) 87 87 * 88 88 * @param int $site_id 89 * 89 90 * @return bool True if site is public, false if private 90 91 */ … … 106 107 107 108 /** 108 * Check if current page is a bbPress forum 109 * Check if current page is a bbPress forum. 109 110 * 110 111 * @since 2.0.0 bbPress (r2549) 111 112 * 112 113 * @param int $post_id Possible post_id to check 114 * 113 115 * @return bool True if it's a forum page, false if not 114 116 */ … … 152 154 153 155 /** 154 * Viewing a single forum 156 * Viewing a single forum. 155 157 * 156 158 * @since 2.0.0 bbPress (r3338) … … 178 180 179 181 /** 180 * Check if current page is a forum edit page 182 * Check if current page is a forum edit page. 181 183 * 182 184 * @since 2.1.0 bbPress (r3553) … … 209 211 210 212 /** 211 * Check if current page is a bbPress topic 213 * Check if current page is a bbPress topic. 212 214 * 213 215 * @since 2.0.0 bbPress (r2549) 214 216 * 215 217 * @param int $post_id Possible post_id to check 218 * 216 219 * @return bool True if it's a topic page, false if not 217 220 */ … … 231 234 232 235 /** 233 * Viewing a single topic 236 * Viewing a single topic. 234 237 * 235 238 * @since 2.0.0 bbPress (r3338) … … 278 281 279 282 /** 280 * Check if current page is a topic edit page 283 * Check if current page is a topic edit page. 281 284 * 282 285 * @since 2.0.0 bbPress (r2753) … … 309 312 310 313 /** 311 * Check if current page is a topic merge page 314 * Check if current page is a topic merge page. 312 315 * 313 316 * @since 2.0.0 bbPress (r2756) … … 330 333 331 334 /** 332 * Check if current page is a topic split page 335 * Check if current page is a topic split page. 333 336 * 334 337 * @since 2.0.0 bbPress (r2756) … … 351 354 352 355 /** 353 * Check if the current page is a topic tag 356 * Check if the current page is a topic tag. 354 357 * 355 358 * @since 2.0.0 bbPress (r3311) … … 382 385 383 386 /** 384 * Check if the current page is editing a topic tag 387 * Check if the current page is editing a topic tag. 385 388 * 386 389 * @since 2.0.0 bbPress (r3346) … … 419 422 420 423 /** 421 * Check if the current post type is one that comes with bbPress 424 * Check if the current post type is one that comes with bbPress. 422 425 * 423 426 * @since 2.0.0 bbPress (r3311) … … 433 436 434 437 // Viewing one of the bbPress post types 435 if ( in_array( get_post_type( $the_post ), array(438 if ( in_array(get_post_type( $the_post ), array( 436 439 bbp_get_forum_post_type(), 437 440 bbp_get_topic_post_type(), 438 bbp_get_reply_post_type() 441 bbp_get_reply_post_type(), 439 442 ), true ) ) { 440 443 $retval = true; … … 446 449 447 450 /** 448 * Check if current page is a bbPress reply 451 * Check if current page is a bbPress reply. 449 452 * 450 453 * @since 2.0.0 bbPress (r2549) 451 454 * 452 455 * @param int $post_id Possible post_id to check 456 * 453 457 * @return bool True if it's a reply page, false if not 454 458 */ … … 468 472 469 473 /** 470 * Check if current page is a reply edit page 474 * Check if current page is a reply edit page. 471 475 * 472 476 * @since 2.0.0 bbPress (r2753) … … 499 503 500 504 /** 501 * Check if current page is a reply move page 505 * Check if current page is a reply move page. 502 506 * 503 507 * @return bool True if it's the reply move page, false if not … … 518 522 519 523 /** 520 * Viewing a single reply 524 * Viewing a single reply. 521 525 * 522 526 * @since 2.0.0 bbPress (r3344) … … 535 539 536 540 // Single and a match 537 if ( is_singular( bbp_get_reply_post_type() ) || ( bbp_is_query_name( 'bbp_single_reply' )) ) {541 if ( is_singular( bbp_get_reply_post_type() ) || bbp_is_query_name( 'bbp_single_reply' ) ) { 538 542 $retval = true; 539 543 } … … 544 548 545 549 /** 546 * Check if current page is a bbPress user's favorites page (profile page )550 * Check if current page is a bbPress user's favorites page (profile page ). 547 551 * 548 552 * @since 2.0.0 bbPress (r2652) … … 568 572 569 573 /** 570 * Check if current page is a bbPress user's subscriptions page (profile page )574 * Check if current page is a bbPress user's subscriptions page (profile page ). 571 575 * 572 576 * @since 2.0.0 bbPress (r2652) … … 593 597 /** 594 598 * Check if current page shows the topics created by a bbPress user (profile 595 * page )599 * page ). 596 600 * 597 601 * @since 2.0.0 bbPress (r2688) … … 618 622 /** 619 623 * Check if current page shows the replies created by a bbPress user (profile 620 * page )624 * page ). 621 625 * 622 626 * @since 2.2.0 bbPress (r4225) … … 642 646 643 647 /** 644 * Check if current page is the currently logged in users author page 648 * Check if current page is the currently logged in users author page. 645 649 * 646 650 * @since 2.0.0 bbPress (r2688) … … 666 670 667 671 /** 668 * Check if current page is the currently logged in users author edit page 672 * Check if current page is the currently logged in users author edit page. 669 673 * 670 674 * @since 2.1.0 bbPress (r3918) … … 686 690 687 691 /** 688 * Check if current page is a user profile page 692 * Check if current page is a user profile page. 689 693 * 690 694 * @since 2.0.0 bbPress (r2688) … … 710 714 711 715 /** 712 * Check if current page is a user profile edit page 716 * Check if current page is a user profile edit page. 713 717 * 714 718 * @since 2.0.0 bbPress (r2688) … … 734 738 735 739 /** 736 * Check if current page is a user profile page 740 * Check if current page is a user profile page. 737 741 * 738 742 * @since 2.2.0 bbPress (r4225) … … 758 762 759 763 /** 760 * Check if current page is a user topics created page 764 * Check if current page is a user topics created page. 761 765 * 762 766 * @since 2.2.0 bbPress (r4225) … … 782 786 783 787 /** 784 * Check if current page is a user replies created page 788 * Check if current page is a user replies created page. 785 789 * 786 790 * @since 2.2.0 bbPress (r4225) … … 806 810 807 811 /** 808 * Check if current page is a user engagements page 812 * Check if current page is a user engagements page. 809 813 * 810 814 * @since 2.6.0 bbPress (r6320) … … 830 834 831 835 /** 832 * Check if current page is a view page 836 * Check if current page is a view page. 833 837 * 834 838 * @since 2.0.0 bbPress (r2789) 835 839 * 836 840 * @global WP_Query $wp_query To check if WP_Query::bbp_is_view is true 841 * 837 842 * @return bool Is it a view page? 838 843 */ … … 860 865 861 866 /** 862 * Check if current page is a search page 867 * Check if current page is a search page. 863 868 * 864 869 * @since 2.3.0 bbPress (r4579) 865 870 * 866 871 * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true 872 * 867 873 * @return bool Is it a search page? 868 874 */ … … 880 886 $wp_query = bbp_get_wp_query(); 881 887 882 // Get the rewrite ID (one time, to avoid repeated calls )888 // Get the rewrite ID (one time, to avoid repeated calls ) 883 889 $rewrite_id = bbp_get_search_rewrite_id(); 884 890 … … 903 909 904 910 /** 905 * Check if current page is a search results page 911 * Check if current page is a search results page. 906 912 * 907 913 * @since 2.4.0 bbPress (r4919) 908 914 * 909 915 * @global WP_Query $wp_query To check if WP_Query::bbp_is_search is true 916 * 910 917 * @return bool Is it a search page? 911 918 */ … … 943 950 944 951 /** 945 * Check if current page is an edit page 952 * Check if current page is an edit page. 946 953 * 947 954 * @since 2.1.0 bbPress (r3585) … … 967 974 968 975 /** 969 * Use the above is_() functions to output a body class for each scenario 976 * Use the above is_() functions to output a body class for each scenario. 970 977 * 971 978 * @since 2.0.0 bbPress (r2926) … … 973 980 * @param array $wp_classes 974 981 * @param array $custom_classes 982 * 975 983 * @return array Body Classes 976 984 */ … … 980 988 $bbp_classes = array(); 981 989 982 /* * Archives**************************************************************/990 /* Archives ***************************************************************/ 983 991 984 992 if ( bbp_is_forum_archive() ) { 985 993 $bbp_classes[] = bbp_get_forum_post_type() . '-archive'; 986 987 994 } elseif ( bbp_is_topic_archive() ) { 988 995 $bbp_classes[] = bbp_get_topic_post_type() . '-archive'; 989 996 990 /** Topic Tags ************************************************************/ 991 997 /* Topic Tags *************************************************************/ 992 998 } elseif ( bbp_is_topic_tag() ) { 993 999 $bbp_classes[] = bbp_get_topic_tag_tax_id(); … … 997 1003 $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-edit'; 998 1004 $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_slug() . '-edit'; 999 $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id() . '-edit'; 1000 1001 /** Components ************************************************************/ 1002 1005 $bbp_classes[] = bbp_get_topic_tag_tax_id() . '-' . bbp_get_topic_tag_id() . '-edit'; 1006 1007 /* Components *************************************************************/ 1003 1008 } elseif ( bbp_is_single_forum() ) { 1004 1009 $bbp_classes[] = bbp_get_forum_post_type(); 1005 1006 1010 } elseif ( bbp_is_single_topic() ) { 1007 1011 $bbp_classes[] = bbp_get_topic_post_type(); 1008 1009 1012 } elseif ( bbp_is_single_reply() ) { 1010 1013 $bbp_classes[] = bbp_get_reply_post_type(); 1011 1012 1014 } elseif ( bbp_is_topic_edit() ) { 1013 1015 $bbp_classes[] = bbp_get_topic_post_type() . '-edit'; 1014 1015 1016 } elseif ( bbp_is_topic_merge() ) { 1016 1017 $bbp_classes[] = bbp_get_topic_post_type() . '-merge'; 1017 1018 1018 } elseif ( bbp_is_topic_split() ) { 1019 1019 $bbp_classes[] = bbp_get_topic_post_type() . '-split'; 1020 1021 1020 } elseif ( bbp_is_reply_edit() ) { 1022 1021 $bbp_classes[] = bbp_get_reply_post_type() . '-edit'; 1023 1024 1022 } elseif ( bbp_is_reply_move() ) { 1025 1023 $bbp_classes[] = bbp_get_reply_post_type() . '-move'; 1026 1027 1024 } elseif ( bbp_is_single_view() ) { 1028 1025 $bbp_classes[] = 'bbp-view'; 1029 1026 $bbp_classes[] = 'bbp-view-' . bbp_get_view_id(); 1030 1027 1031 /** User ******************************************************************/ 1032 1028 /* User *******************************************************************/ 1033 1029 } elseif ( bbp_is_single_user_edit() ) { 1034 1030 $bbp_classes[] = 'bbp-user-edit'; 1035 1031 $bbp_classes[] = 'single'; 1036 1032 $bbp_classes[] = 'singular'; 1037 1038 1033 } elseif ( bbp_is_single_user() ) { 1039 1034 $bbp_classes[] = 'bbp-user-page'; 1040 1035 $bbp_classes[] = 'single'; 1041 1036 $bbp_classes[] = 'singular'; 1042 1043 1037 } elseif ( bbp_is_user_home() ) { 1044 1038 $bbp_classes[] = 'bbp-user-home'; 1045 1039 $bbp_classes[] = 'single'; 1046 1040 $bbp_classes[] = 'singular'; 1047 1048 1041 } elseif ( bbp_is_user_home_edit() ) { 1049 1042 $bbp_classes[] = 'bbp-user-home-edit'; 1050 1043 $bbp_classes[] = 'single'; 1051 1044 $bbp_classes[] = 'singular'; 1052 1053 1045 } elseif ( bbp_is_topics_created() ) { 1054 1046 $bbp_classes[] = 'bbp-topics-created'; 1055 1047 $bbp_classes[] = 'single'; 1056 1048 $bbp_classes[] = 'singular'; 1057 1058 1049 } elseif ( bbp_is_replies_created() ) { 1059 1050 $bbp_classes[] = 'bbp-replies-created'; 1060 1051 $bbp_classes[] = 'single'; 1061 1052 $bbp_classes[] = 'singular'; 1062 1063 1053 } elseif ( bbp_is_favorites() ) { 1064 1054 $bbp_classes[] = 'bbp-favorites'; 1065 1055 $bbp_classes[] = 'single'; 1066 1056 $bbp_classes[] = 'singular'; 1067 1068 1057 } elseif ( bbp_is_subscriptions() ) { 1069 1058 $bbp_classes[] = 'bbp-subscriptions'; … … 1071 1060 $bbp_classes[] = 'singular'; 1072 1061 1073 /** Search ****************************************************************/ 1074 1062 /* Search *****************************************************************/ 1075 1063 } elseif ( bbp_is_search() ) { 1076 1064 $bbp_classes[] = 'bbp-search'; 1077 1065 $bbp_classes[] = 'forum-search'; 1078 1079 1066 } elseif ( bbp_is_search_results() ) { 1080 1067 $bbp_classes[] = 'bbp-search-results'; 1081 1068 $bbp_classes[] = 'forum-search-results'; 1082 1069 1083 /** Shortcodes ************************************************************/ 1084 1070 /* Shortcodes *************************************************************/ 1085 1071 } elseif ( bbp_has_shortcode() ) { 1086 1072 $bbp_classes[] = 'bbp-shortcode'; 1087 1073 } 1088 1074 1089 /* * General***************************************************************/1075 /* General ****************************************************************/ 1090 1076 1091 1077 // Any page with bbPress content … … 1098 1084 1099 1085 // Merge WP classes with bbPress classes and remove any duplicates 1100 $classes = array_unique( array_merge( (array) $bbp_classes, (array) $wp_classes ) );1101 1102 // Deprecated filter (do not use )1086 $classes = array_unique(array_merge( (array) $bbp_classes, (array) $wp_classes ) ); 1087 1088 // Deprecated filter (do not use ) 1103 1089 $classes = apply_filters( 'bbp_get_the_body_class', $classes, $bbp_classes, $wp_classes, $custom_classes ); 1104 1090 … … 1124 1110 $done = true; 1125 1111 1126 ?>1112 ?> 1127 1113 1128 1114 <script type="text/javascript" id="bbp-swap-no-js-body-class"> … … 1146 1132 * 1147 1133 * @param string $text 1134 * 1148 1135 * @return bool 1149 1136 */ … … 1181 1168 1182 1169 /** 1183 * Use the above is_() functions to return if in any bbPress page 1170 * Use the above is_() functions to return if in any bbPress page. 1184 1171 * 1185 1172 * @since 2.0.0 bbPress (r3344) … … 1194 1181 // Bail if main query has not been populated. 1195 1182 if ( ! bbp_get_wp_query() ) { 1196 _doing_it_wrong( __FUNCTION__, esc_html__( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '2.7.0' ); 1183 _doing_it_wrong(__FUNCTION__, esc_html__( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '2.7.0' ); 1184 1197 1185 return $retval; 1198 1186 } 1199 1187 1200 /* * Archives**************************************************************/1188 /* Archives ***************************************************************/ 1201 1189 1202 1190 if ( bbp_is_forum_archive() ) { 1203 1191 $retval = true; 1204 1205 1192 } elseif ( bbp_is_topic_archive() ) { 1206 1193 $retval = true; 1207 1194 1208 /** Topic Tags ************************************************************/ 1209 1195 /* Topic Tags *************************************************************/ 1210 1196 } elseif ( bbp_is_topic_tag() ) { 1211 1197 $retval = true; 1212 1213 1198 } elseif ( bbp_is_topic_tag_edit() ) { 1214 1199 $retval = true; 1215 1200 1216 /** Components ************************************************************/ 1217 1201 /* Components *************************************************************/ 1218 1202 } elseif ( bbp_is_single_forum() ) { 1219 1203 $retval = true; 1220 1221 1204 } elseif ( bbp_is_single_topic() ) { 1222 1205 $retval = true; 1223 1224 1206 } elseif ( bbp_is_single_reply() ) { 1225 1207 $retval = true; 1226 1227 1208 } elseif ( bbp_is_topic_edit() ) { 1228 1209 $retval = true; 1229 1230 1210 } elseif ( bbp_is_topic_merge() ) { 1231 1211 $retval = true; 1232 1233 1212 } elseif ( bbp_is_topic_split() ) { 1234 1213 $retval = true; 1235 1236 1214 } elseif ( bbp_is_reply_edit() ) { 1237 1215 $retval = true; 1238 1239 1216 } elseif ( bbp_is_reply_move() ) { 1240 1217 $retval = true; 1241 1242 1218 } elseif ( bbp_is_single_view() ) { 1243 1219 $retval = true; 1244 1220 1245 /** User ******************************************************************/ 1246 1221 /* User *******************************************************************/ 1247 1222 } elseif ( bbp_is_single_user_edit() ) { 1248 1223 $retval = true; 1249 1250 1224 } elseif ( bbp_is_single_user() ) { 1251 1225 $retval = true; 1252 1253 1226 } elseif ( bbp_is_user_home() ) { 1254 1227 $retval = true; 1255 1256 1228 } elseif ( bbp_is_user_home_edit() ) { 1257 1229 $retval = true; 1258 1259 1230 } elseif ( bbp_is_topics_created() ) { 1260 1231 $retval = true; 1261 1262 1232 } elseif ( bbp_is_replies_created() ) { 1263 1233 $retval = true; 1264 1265 1234 } elseif ( bbp_is_favorites() ) { 1266 1235 $retval = true; 1267 1268 1236 } elseif ( bbp_is_subscriptions() ) { 1269 1237 $retval = true; 1270 1238 1271 /** Search ****************************************************************/ 1272 1239 /* Search *****************************************************************/ 1273 1240 } elseif ( bbp_is_search() ) { 1274 1241 $retval = true; 1275 1276 1242 } elseif ( bbp_is_search_results() ) { 1277 1243 $retval = true; 1278 1244 1279 /** Shortcodes ************************************************************/ 1280 1245 /* Shortcodes *************************************************************/ 1281 1246 } elseif ( bbp_has_shortcode() ) { 1282 1247 $retval = true; 1283 1248 } 1284 1249 1285 /* * Done******************************************************************/1250 /* Done *******************************************************************/ 1286 1251 1287 1252 // Filter & return … … 1292 1257 1293 1258 /** 1294 * Output the login form action url 1259 * Output the login form action url. 1295 1260 * 1296 1261 * @since 2.0.0 bbPress (r2815) 1297 1262 * 1298 1263 * @param array $args This function supports these arguments: 1299 * - action: The action being taken1300 * - context: The context the action is being taken from1264 * - action: The action being taken 1265 * - context: The context the action is being taken from 1301 1266 */ 1302 1267 function bbp_wp_login_action( $args = array() ) { … … 1304 1269 } 1305 1270 1306 /**1307 * Return the login form action url 1308 *1309 * @since 2.6.0 bbPress (r5684)1310 *1311 * @param array $args This function supports these arguments:1312 *- action: The action being taken1313 *- context: The context the action is being taken from1314 */1315 function bbp_get_wp_login_action( $args = array() ) {1316 1317 // Parse arguments against default values1318 $r = bbp_parse_args( $args, array(1319 'action' => '',1320 'context' => '',1321 'url' => 'wp-login.php'1322 ), 'login_action' );1323 1324 // Add action as query arg1325 $login_url = ! empty( $r['action'] )1326 ? add_query_arg(array( 'action' => $r['action'] ), $r['url'] )1327 : $r['url'];1328 1329 $login_url = site_url( $login_url, $r['context'] );1330 1331 // Filter & return1332 return apply_filters( 'bbp_get_wp_login_action', $login_url, $r, $args );1333 }1271 /** 1272 * Return the login form action url. 1273 * 1274 * @since 2.6.0 bbPress (r5684) 1275 * 1276 * @param array $args This function supports these arguments: 1277 * - action: The action being taken 1278 * - context: The context the action is being taken from 1279 */ 1280 function bbp_get_wp_login_action( $args = array() ) { 1281 1282 // Parse arguments against default values 1283 $r = bbp_parse_args( $args, array( 1284 'action' => '', 1285 'context' => '', 1286 'url' => 'wp-login.php', 1287 ), 'login_action' ); 1288 1289 // Add action as query arg 1290 $login_url = ! empty( $r['action'] ) 1291 ? add_query_arg(array( 'action' => $r['action'] ), $r['url'] ) 1292 : $r['url']; 1293 1294 $login_url = site_url( $login_url, $r['context'] ); 1295 1296 // Filter & return 1297 return apply_filters( 'bbp_get_wp_login_action', $login_url, $r, $args ); 1298 } 1334 1299 1335 1300 /** … … 1370 1335 * @since 2.0.0 bbPress (r2815) 1371 1336 * 1372 * @param string $request Name of $_REQUEST to look for1337 * @param string $request Name of $_REQUEST to look for 1373 1338 * @param string $input_type Type of input. Default: text. Accepts: 1374 * textarea|password|select|radio|checkbox1339 * textarea|password|select|radio|checkbox 1375 1340 */ 1376 1341 function bbp_sanitize_val( $request = '', $input_type = 'text' ) { 1377 1342 echo bbp_get_sanitize_val( $request, $input_type ); 1378 1343 } 1379 /** 1380 * Return sanitized $_REQUEST value. 1381 * 1382 * Use the $input_type parameter to properly process the value. This 1383 * ensures correct sanitization of the value for the receiving input. 1384 * 1385 * @since 2.0.0 bbPress (r2815) 1386 * 1387 * @param string $request Name of $_REQUEST to look for 1388 * @param string $input_type Type of input. Default: text. Accepts: 1389 * textarea|password|select|radio|checkbox 1390 * 1391 * @return string Sanitized value ready for screen display 1392 */ 1393 function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) { 1394 1395 // Check that requested 1396 if ( empty( $_REQUEST[ $request ] ) ) { 1397 return false; 1398 } 1399 1400 // Set request varaible 1401 $pre_ret_val = $_REQUEST[ $request ]; 1402 1403 // Treat different kinds of fields in different ways 1404 switch ( $input_type ) { 1405 case 'text' : 1406 case 'textarea' : 1407 $retval = esc_attr( wp_unslash( $pre_ret_val ) ); 1408 break; 1409 1410 case 'password' : 1411 case 'select' : 1412 case 'radio' : 1413 case 'checkbox' : 1414 default : 1415 $retval = esc_attr( $pre_ret_val ); 1416 break; 1417 } 1418 1419 // Filter & return 1420 return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type ); 1421 } 1422 1423 /** 1424 * Output the current tab index of a given form 1344 1345 /** 1346 * Return sanitized $_REQUEST value. 1347 * 1348 * Use the $input_type parameter to properly process the value. This 1349 * ensures correct sanitization of the value for the receiving input. 1350 * 1351 * @since 2.0.0 bbPress (r2815) 1352 * 1353 * @param string $request Name of $_REQUEST to look for 1354 * @param string $input_type Type of input. Default: text. Accepts: 1355 * textarea|password|select|radio|checkbox 1356 * 1357 * @return string Sanitized value ready for screen display 1358 */ 1359 function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) { 1360 1361 // Check that requested 1362 if ( empty( $_REQUEST[ $request ] ) ) { 1363 return false; 1364 } 1365 1366 // Set request varaible 1367 $pre_ret_val = $_REQUEST[ $request ]; 1368 1369 // Treat different kinds of fields in different ways 1370 switch ( $input_type ) { 1371 case 'text': 1372 case 'textarea': 1373 $retval = esc_attr(wp_unslash( $pre_ret_val ) ); 1374 break; 1375 1376 case 'password': 1377 case 'select': 1378 case 'radio': 1379 case 'checkbox': 1380 default: 1381 $retval = esc_attr( $pre_ret_val ); 1382 break; 1383 } 1384 1385 // Filter & return 1386 return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type ); 1387 } 1388 1389 /** 1390 * Output the current tab index of a given form. 1425 1391 * 1426 1392 * Use this function to handle the tab indexing of user facing forms within a … … 1429 1395 * 1430 1396 * @since 2.0.0 bbPress (r2810) 1431 *1432 1397 * @deprecated 2.6.0 bbPress (r5561) 1433 * 1434 * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket1398 * @see https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket 1399 * 1435 1400 * @param int $auto_increment Optional. Default true. Set to false to prevent 1436 * increment1401 * increment 1437 1402 */ 1438 1403 function bbp_tab_index( $auto_increment = true ) { … … 1440 1405 } 1441 1406 1442 /**1443 * Return the current tab index of a given form 1444 *1445 * Use this function to handle the tab indexing of user facing forms1446 * within a template file. Calling this function will automatically1447 * increment the global tab index by default.1448 *1449 * @since 2.0.0 bbPress (r2810)1450 * 1451 * @deprecated 2.6.0 bbPress (r5561) 1452 *1453 * @link https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket 1454 * @param int $auto_increment Optional. Default true. Set to false to 1455 * prevent the increment 1456 * @return int $bbp->tab_index The global tab index1457 */1458 function bbp_get_tab_index( $auto_increment = true ) {1459 $bbp = bbpress();1460 1461 if ( true === $auto_increment ) {1462 ++$bbp->tab_index;1463 }1464 1465 // Filter & return1466 return apply_filters( 'bbp_get_tab_index', (int) $bbp->tab_index );1467 }1407 /** 1408 * Return the current tab index of a given form. 1409 * 1410 * Use this function to handle the tab indexing of user facing forms 1411 * within a template file. Calling this function will automatically 1412 * increment the global tab index by default. 1413 * 1414 * @since 2.0.0 bbPress (r2810) 1415 * @deprecated 2.6.0 bbPress (r5561) 1416 * @see https://bbpress.trac.wordpress.org/attachment/ticket/2714 Trac Ticket 1417 * 1418 * @param int $auto_increment Optional. Default true. Set to false to 1419 * prevent the increment 1420 * 1421 * @return int $bbp->tab_index The global tab index 1422 */ 1423 function bbp_get_tab_index( $auto_increment = true ) { 1424 $bbp = bbpress(); 1425 1426 if ( true === $auto_increment ) { 1427 ++$bbp->tab_index; 1428 } 1429 1430 // Filter & return 1431 return apply_filters( 'bbp_get_tab_index', (int) $bbp->tab_index ); 1432 } 1468 1433 1469 1434 /** … … 1483 1448 } 1484 1449 1485 /**1486 * Return a "tabindex" attribute for an element, if an index was passed.1487 *1488 * This helper function is in use, but it is generally considered impolite to1489 * override the "tabindex" attribute beyond what the browser naturally assigns.1490 *1491 * Most internal usages pass `false` which results in no attribute being used.1492 *1493 * @since 2.6.0 bbPress (r6424)1494 *1495 * @param mixed $tab False to skip, any integer to use1496 *1497 * @return string1498 */1499 function bbp_get_tab_index_attribute( $tab = false ) {1500 1501 // Get attribute1502 $attr = is_numeric( $tab )1503 ? ' tabindex="' . (int) $tab . '"'1504 : '';1505 1506 // Filter & return1507 return apply_filters( 'bbp_get_tab_index_attribute', $attr, $tab );1508 }1450 /** 1451 * Return a "tabindex" attribute for an element, if an index was passed. 1452 * 1453 * This helper function is in use, but it is generally considered impolite to 1454 * override the "tabindex" attribute beyond what the browser naturally assigns. 1455 * 1456 * Most internal usages pass `false` which results in no attribute being used. 1457 * 1458 * @since 2.6.0 bbPress (r6424) 1459 * 1460 * @param mixed $tab False to skip, any integer to use 1461 * 1462 * @return string 1463 */ 1464 function bbp_get_tab_index_attribute( $tab = false ) { 1465 1466 // Get attribute 1467 $attr = is_numeric( $tab ) 1468 ? ' tabindex="' . (int) $tab . '"' 1469 : ''; 1470 1471 // Filter & return 1472 return apply_filters( 'bbp_get_tab_index_attribute', $attr, $tab ); 1473 } 1509 1474 1510 1475 /** … … 1521 1486 echo bbp_get_dropdown( $args ); 1522 1487 } 1523 /** 1524 * Return a select box allowing to pick which forum/topic a new 1525 * topic/reply belongs in. 1488 /** 1489 * Return a select box allowing to pick which forum/topic a new 1490 * topic/reply belongs in. 1491 * 1492 * @since 2.0.0 bbPress (r2746) 1493 * 1494 * @param array $args The function supports these args: 1495 * - post_type: Post type, defaults to bbp_get_forum_post_type() ( bbp_forum) 1496 * - selected: Selected ID, to not have any value as selected, pass 1497 * anything smaller than 0 (due to the nature of select 1498 * box, the first value would of course be selected - 1499 * though you can have that as none (pass 'show_none' arg) ) 1500 * - orderby: Defaults to 'menu_order title' 1501 * - post_parent: Post parent. Defaults to 0 1502 * - post_status: Which all post_statuses to find in? Can be an array 1503 * or CSV of publish, category, closed, private, spam, 1504 * trash (based on post type ) - if not set, these are 1505 * automatically determined based on the post_type 1506 * - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get 1507 * all posts 1508 * - walker: Which walker to use? Defaults to 1509 * {@link BBP_Walker_Dropdown} 1510 * - select_id: ID of the select box. Defaults to 'bbp_forum_id' 1511 * - tab: Deprecated. Tabindex value. False or integer 1512 * - options_only: Show only <options>? No <select>? 1513 * - show_none: Boolean or String __( '— No Forum —', 'bbpress' ) 1514 * - disable_categories: Disable forum categories and closed forums? 1515 * Defaults to true. Only for forums and when 1516 * 1517 * @return string The dropdown 1518 */ 1519 function bbp_get_dropdown( $args = array() ) { 1520 1521 // Setup return value 1522 $retval = ''; 1523 1524 /** Arguments *************************************************************/ 1525 1526 // Parse arguments against default values 1527 $r = bbp_parse_args( $args, array( 1528 // Support for get_posts() 1529 'post_type' => bbp_get_forum_post_type(), 1530 'post_parent' => null, 1531 'post_status' => null, 1532 'selected' => 0, 1533 'include' => array(), 1534 'exclude' => array(), 1535 'numberposts' => -1, 1536 'orderby' => 'menu_order title', 1537 'order' => 'ASC', 1538 1539 // Preloaded content 1540 'posts' => array(), 1541 1542 // Custom hierarchy walkers 1543 'walker' => '', 1544 1545 // Output-related 1546 'select_id' => 'bbp_forum_id', 1547 'select_class' => 'bbp_dropdown', 1548 'tab' => false, 1549 'options_only' => false, 1550 'show_none' => false, 1551 'disable_categories' => true, 1552 'disabled' => '', 1553 ), 'get_dropdown' ); 1554 1555 // Fallback to our walker 1556 if ( empty( $r['walker'] ) ) { 1557 $r['walker'] = new BBP_Walker_Dropdown(); 1558 $r['walker']->tree_type = $r['post_type']; 1559 } 1560 1561 // Force 0 1562 if ( is_numeric( $r['selected'] ) && ( $r['selected'] < 0 ) ) { 1563 $r['selected'] = 0; 1564 } 1565 1566 // Force array 1567 if ( ! empty( $r['include'] ) && ! is_array( $r['include'] ) ) { 1568 $r['include'] = explode( ',', $r['include'] ); 1569 } 1570 1571 // Force array 1572 if ( ! empty( $r['exclude'] ) && ! is_array( $r['exclude'] ) ) { 1573 $r['exclude'] = explode( ',', $r['exclude'] ); 1574 } 1575 1576 /* Setup Posts ************************************************************/ 1577 1578 /* 1579 * Allow passing of custom posts data 1526 1580 * 1527 * @since 2.0.0 bbPress (r2746) 1528 * 1529 * @param array $args The function supports these args: 1530 * - post_type: Post type, defaults to bbp_get_forum_post_type() (bbp_forum) 1531 * - selected: Selected ID, to not have any value as selected, pass 1532 * anything smaller than 0 (due to the nature of select 1533 * box, the first value would of course be selected - 1534 * though you can have that as none (pass 'show_none' arg)) 1535 * - orderby: Defaults to 'menu_order title' 1536 * - post_parent: Post parent. Defaults to 0 1537 * - post_status: Which all post_statuses to find in? Can be an array 1538 * or CSV of publish, category, closed, private, spam, 1539 * trash (based on post type) - if not set, these are 1540 * automatically determined based on the post_type 1541 * - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get 1542 * all posts 1543 * - walker: Which walker to use? Defaults to 1544 * {@link BBP_Walker_Dropdown} 1545 * - select_id: ID of the select box. Defaults to 'bbp_forum_id' 1546 * - tab: Deprecated. Tabindex value. False or integer 1547 * - options_only: Show only <options>? No <select>? 1548 * - show_none: Boolean or String __( '— No Forum —', 'bbpress' ) 1549 * - disable_categories: Disable forum categories and closed forums? 1550 * Defaults to true. Only for forums and when 1551 * @return string The dropdown 1581 * @see bbp_get_reply_to_dropdown() as an example 1552 1582 */ 1553 function bbp_get_dropdown( $args = array() ) { 1554 1555 // Setup return value 1556 $retval = ''; 1557 1558 /** Arguments *********************************************************/ 1559 1560 // Parse arguments against default values 1561 $r = bbp_parse_args( $args, array( 1562 1563 // Support for get_posts() 1564 'post_type' => bbp_get_forum_post_type(), 1565 'post_parent' => null, 1566 'post_status' => null, 1567 'selected' => 0, 1568 'include' => array(), 1569 'exclude' => array(), 1570 'numberposts' => -1, 1571 'orderby' => 'menu_order title', 1572 'order' => 'ASC', 1573 1574 // Preloaded content 1575 'posts' => array(), 1576 1577 // Custom hierarchy walkers 1578 'walker' => '', 1579 1580 // Output-related 1581 'select_id' => 'bbp_forum_id', 1582 'select_class' => 'bbp_dropdown', 1583 'tab' => false, 1584 'options_only' => false, 1585 'show_none' => false, 1586 'disable_categories' => true, 1587 'disabled' => '' 1588 ), 'get_dropdown' ); 1589 1590 // Fallback to our walker 1591 if ( empty( $r['walker'] ) ) { 1592 $r['walker'] = new BBP_Walker_Dropdown(); 1593 $r['walker']->tree_type = $r['post_type']; 1583 if ( empty( $r['posts'] ) ) { 1584 $r['posts'] = get_posts( array( 1585 'post_type' => $r['post_type'], 1586 'post_status' => $r['post_status'], 1587 'post_parent' => $r['post_parent'], 1588 'include' => $r['include'], 1589 'exclude' => $r['exclude'], 1590 'numberposts' => $r['numberposts'], 1591 'orderby' => $r['orderby'], 1592 'order' => $r['order'], 1593 ) ); 1594 } 1595 1596 /* Drop Down **************************************************************/ 1597 1598 // Build the opening tag for the select element 1599 if ( empty( $r['options_only'] ) ) { 1600 1601 // Should this select appear disabled? 1602 $disabled = disabled( isset( bbpress()->options[ $r['disabled'] ] ), true, false ); 1603 1604 // Setup the tab index attribute 1605 $tab = ! empty( $r['tab'] ) 1606 ? ' tabindex="'. intval( $r['tab'] ) . '"' 1607 : ''; 1608 1609 // Open the select tag 1610 $retval .= '<select name="' . esc_attr( $r['select_id'] ) . '" id="' . esc_attr( $r['select_id'] ) . '" class="' . esc_attr( $r['select_class'] ) . '"' . $disabled . $tab . '>' . "\n"; 1611 } 1612 1613 // Display a leading 'no-value' option, with or without custom text 1614 if ( ! empty( $r['show_none'] ) || ! empty( $r['none_found'] ) ) { 1615 1616 // Open the 'no-value' option tag 1617 $retval .= "\t<option value=\"\" class=\"level-0\">"; 1618 1619 // Use deprecated 'none_found' first for backpat 1620 if ( ! empty( $r['none_found'] ) && is_string( $r['none_found'] ) ) { 1621 $retval .= esc_html( $r['none_found'] ); 1622 1623 // Use 'show_none' second 1624 } elseif ( ! empty( $r['show_none'] ) && is_string( $r['show_none'] ) ) { 1625 $retval .= esc_html( $r['show_none'] ); 1626 1627 // Otherwise, make some educated guesses 1628 } else { 1629 1630 // Switch the response based on post type 1631 switch ( $r['post_type'] ) { 1632 // Topics 1633 case bbp_get_topic_post_type(): 1634 $retval .= esc_html__( 'No topics available', 'bbpress' ); 1635 break; 1636 1637 // Forums 1638 case bbp_get_forum_post_type(): 1639 $retval .= esc_html__( 'No forums available', 'bbpress' ); 1640 break; 1641 1642 // Any other 1643 default: 1644 $retval .= esc_html__( 'None available', 'bbpress' ); 1645 break; 1646 } 1594 1647 } 1595 1648 1596 // Force 0 1597 if ( is_numeric( $r['selected'] ) && ( $r['selected'] < 0 ) ) { 1598 $r['selected'] = 0; 1599 } 1600 1601 // Force array 1602 if ( ! empty( $r['include'] ) && ! is_array( $r['include'] ) ) { 1603 $r['include'] = explode( ',', $r['include'] ); 1604 } 1605 1606 // Force array 1607 if ( ! empty( $r['exclude'] ) && ! is_array( $r['exclude'] ) ) { 1608 $r['exclude'] = explode( ',', $r['exclude'] ); 1609 } 1610 1611 /** Setup Posts *******************************************************/ 1612 1613 /** 1614 * Allow passing of custom posts data 1615 * 1616 * @see bbp_get_reply_to_dropdown() as an example 1617 */ 1618 if ( empty( $r['posts'] ) ) { 1619 $r['posts'] = get_posts( array( 1620 'post_type' => $r['post_type'], 1621 'post_status' => $r['post_status'], 1622 'post_parent' => $r['post_parent'], 1623 'include' => $r['include'], 1624 'exclude' => $r['exclude'], 1625 'numberposts' => $r['numberposts'], 1626 'orderby' => $r['orderby'], 1627 'order' => $r['order'], 1628 ) ); 1629 } 1630 1631 /** Drop Down *********************************************************/ 1632 1633 // Build the opening tag for the select element 1634 if ( empty( $r['options_only'] ) ) { 1635 1636 // Should this select appear disabled? 1637 $disabled = disabled( isset( bbpress()->options[ $r['disabled'] ] ), true, false ); 1638 1639 // Setup the tab index attribute 1640 $tab = ! empty( $r['tab'] ) ? ' tabindex="' . intval( $r['tab'] ) . '"' : ''; 1641 1642 // Open the select tag 1643 $retval .= '<select name="' . esc_attr( $r['select_id'] ) . '" id="' . esc_attr( $r['select_id'] ) . '" class="' . esc_attr( $r['select_class'] ) . '"' . $disabled . $tab . '>' . "\n"; 1644 } 1645 1646 // Display a leading 'no-value' option, with or without custom text 1647 if ( ! empty( $r['show_none'] ) || ! empty( $r['none_found'] ) ) { 1648 1649 // Open the 'no-value' option tag 1650 $retval .= "\t<option value=\"\" class=\"level-0\">"; 1651 1652 // Use deprecated 'none_found' first for backpat 1653 if ( ! empty( $r['none_found'] ) && is_string( $r['none_found'] ) ) { 1654 $retval .= esc_html( $r['none_found'] ); 1655 1656 // Use 'show_none' second 1657 } elseif ( ! empty( $r['show_none'] ) && is_string( $r['show_none'] ) ) { 1658 $retval .= esc_html( $r['show_none'] ); 1659 1660 // Otherwise, make some educated guesses 1661 } else { 1662 1663 // Switch the response based on post type 1664 switch ( $r['post_type'] ) { 1665 1666 // Topics 1667 case bbp_get_topic_post_type() : 1668 $retval .= esc_html__( 'No topics available', 'bbpress' ); 1669 break; 1670 1671 // Forums 1672 case bbp_get_forum_post_type() : 1673 $retval .= esc_html__( 'No forums available', 'bbpress' ); 1674 break; 1675 1676 // Any other 1677 default : 1678 $retval .= esc_html__( 'None available', 'bbpress' ); 1679 break; 1680 } 1681 } 1682 1683 // Close the 'no-value' option tag 1684 $retval .= '</option>'; 1685 } 1686 1687 // Items found so walk the tree 1688 if ( ! empty( $r['posts'] ) ) { 1689 $retval .= walk_page_dropdown_tree( $r['posts'], 0, $r ); 1690 } 1691 1692 // Close the selecet tag 1693 if ( empty( $r['options_only'] ) ) { 1694 $retval .= '</select>'; 1695 } 1696 1697 // Filter & return 1698 return apply_filters( 'bbp_get_dropdown', $retval, $r, $args ); 1699 } 1700 1701 /** 1702 * Output the required hidden fields when creating/editing a forum 1649 // Close the 'no-value' option tag 1650 $retval .= '</option>'; 1651 } 1652 1653 // Items found so walk the tree 1654 if ( ! empty( $r['posts'] ) ) { 1655 $retval .= walk_page_dropdown_tree( $r['posts'], 0, $r ); 1656 } 1657 1658 // Close the selecet tag 1659 if ( empty( $r['options_only'] ) ) { 1660 $retval .= '</select>'; 1661 } 1662 1663 // Filter & return 1664 return apply_filters( 'bbp_get_dropdown', $retval, $r, $args ); 1665 } 1666 1667 /** 1668 * Output the required hidden fields when creating/editing a forum. 1703 1669 * 1704 1670 * @since 2.1.0 bbPress (r3553) 1705 1671 */ 1706 1672 function bbp_forum_form_fields() { 1707 1708 if ( bbp_is_forum_edit() ) : ?> 1673 if ( bbp_is_forum_edit() ) { ?> 1709 1674 1710 1675 <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-forum" /> 1711 1676 <input type="hidden" name="bbp_forum_id" id="bbp_forum_id" value="<?php bbp_forum_id(); ?>" /> 1712 1677 1713 <?php if ( current_user_can( 'unfiltered_html' ) ) :1678 <?php if ( current_user_can( 'unfiltered_html' ) ) { 1714 1679 wp_nonce_field( 'bbp-unfiltered-html-forum_' . bbp_get_forum_id(), '_bbp_unfiltered_html_forum', false ); 1715 endif;?>1680 } ?> 1716 1681 1717 1682 <?php wp_nonce_field( 'bbp-edit-forum_' . bbp_get_forum_id() ); 1718 1719 else : 1720 1721 if ( bbp_is_single_forum() ) : ?> 1683 } else { 1684 if ( bbp_is_single_forum() ) { ?> 1722 1685 1723 1686 <input type="hidden" name="bbp_forum_parent_id" id="bbp_forum_parent_id" value="<?php bbp_forum_parent_id(); ?>" /> 1724 1687 1725 <?php endif;?>1688 <?php } ?> 1726 1689 1727 1690 <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-forum" /> 1728 1691 1729 <?php if ( current_user_can( 'unfiltered_html' ) ) :1692 <?php if ( current_user_can( 'unfiltered_html' ) ) { 1730 1693 wp_nonce_field( 'bbp-unfiltered-html-forum_new', '_bbp_unfiltered_html_forum', false ); 1731 endif;?>1694 } ?> 1732 1695 1733 1696 <?php wp_nonce_field( 'bbp-new-forum' ); 1734 1735 endif; 1736 } 1737 1738 /** 1739 * Output the required hidden fields when creating/editing a topic 1697 } 1698 } 1699 1700 /** 1701 * Output the required hidden fields when creating/editing a topic. 1740 1702 * 1741 1703 * @since 2.0.0 bbPress (r2753) 1742 1704 */ 1743 1705 function bbp_topic_form_fields() { 1744 1745 if ( bbp_is_topic_edit() ) : ?> 1706 if ( bbp_is_topic_edit() ) { ?> 1746 1707 1747 1708 <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-topic" /> 1748 1709 <input type="hidden" name="bbp_topic_id" id="bbp_topic_id" value="<?php bbp_topic_id(); ?>" /> 1749 1710 1750 <?php if ( current_user_can( 'unfiltered_html' ) ) :1711 <?php if ( current_user_can( 'unfiltered_html' ) ) { 1751 1712 wp_nonce_field( 'bbp-unfiltered-html-topic_' . bbp_get_topic_id(), '_bbp_unfiltered_html_topic', false ); 1752 endif;?>1713 } ?> 1753 1714 1754 1715 <?php wp_nonce_field( 'bbp-edit-topic_' . bbp_get_topic_id() ); 1755 1756 else : 1757 1758 if ( bbp_is_single_forum() ) : ?> 1716 } else { 1717 if ( bbp_is_single_forum() ) { ?> 1759 1718 1760 1719 <input type="hidden" name="bbp_forum_id" id="bbp_forum_id" value="<?php bbp_forum_id(); ?>" /> 1761 1720 1762 <?php endif;?>1721 <?php } ?> 1763 1722 1764 1723 <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-topic" /> 1765 1724 1766 <?php if ( current_user_can( 'unfiltered_html' ) ) :1725 <?php if ( current_user_can( 'unfiltered_html' ) ) { 1767 1726 wp_nonce_field( 'bbp-unfiltered-html-topic_new', '_bbp_unfiltered_html_topic', false ); 1768 endif;?>1727 } ?> 1769 1728 1770 1729 <?php wp_nonce_field( 'bbp-new-topic' ); 1771 1772 endif; 1773 } 1774 1775 /** 1776 * Output the required hidden fields when creating/editing a reply 1730 } 1731 } 1732 1733 /** 1734 * Output the required hidden fields when creating/editing a reply. 1777 1735 * 1778 1736 * @since 2.0.0 bbPress (r2753) 1779 1737 */ 1780 1738 function bbp_reply_form_fields() { 1781 1782 if ( bbp_is_reply_edit() ) : ?> 1739 if ( bbp_is_reply_edit() ) { ?> 1783 1740 1784 1741 <input type="hidden" name="bbp_reply_id" id="bbp_reply_id" value="<?php bbp_reply_id(); ?>" /> 1785 1742 <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-reply" /> 1786 1743 1787 <?php if ( current_user_can( 'unfiltered_html' ) ) :1788 wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_reply_id(), '_bbp_unfiltered_html_reply', false );1789 endif;?>1744 <?php if ( current_user_can( 'unfiltered_html' ) ) { 1745 wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_reply_id(), '_bbp_unfiltered_html_reply', false ); 1746 } ?> 1790 1747 1791 1748 <?php wp_nonce_field( 'bbp-edit-reply_' . bbp_get_reply_id() ); 1792 1793 else : ?> 1749 } else { ?> 1794 1750 1795 1751 <input type="hidden" name="bbp_topic_id" id="bbp_topic_id" value="<?php bbp_topic_id(); ?>" /> … … 1797 1753 <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-reply" /> 1798 1754 1799 <?php if ( current_user_can( 'unfiltered_html' ) ) :1800 wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_topic_id(), '_bbp_unfiltered_html_reply', false );1801 endif;?>1755 <?php if ( current_user_can( 'unfiltered_html' ) ) { 1756 wp_nonce_field( 'bbp-unfiltered-html-reply_' . bbp_get_topic_id(), '_bbp_unfiltered_html_reply', false ); 1757 } ?> 1802 1758 1803 1759 <?php wp_nonce_field( 'bbp-new-reply' ); 1804 1760 1805 1761 // Show redirect field if not viewing a specific topic 1806 if ( bbp_is_query_name( 'bbp_single_topic' ) ) :1762 if ( bbp_is_query_name( 'bbp_single_topic' ) ) { 1807 1763 $redirect_to = apply_filters( 'bbp_reply_form_redirect_to', get_permalink() ); 1808 1764 bbp_redirect_to_field( $redirect_to ); 1809 endif;1810 endif;1811 } 1812 1813 /** 1814 * Output the required hidden fields when editing a user 1765 } 1766 } 1767 } 1768 1769 /** 1770 * Output the required hidden fields when editing a user. 1815 1771 * 1816 1772 * @since 2.0.0 bbPress (r2690) … … 1826 1782 1827 1783 /** 1828 * Merge topic form fields 1784 * Merge topic form fields. 1829 1785 * 1830 1786 * Output the required hidden fields when merging a topic … … 1842 1798 1843 1799 /** 1844 * Split topic form fields 1800 * Split topic form fields. 1845 1801 * 1846 1802 * Output the required hidden fields when splitting a topic … … 1858 1814 1859 1815 /** 1860 * Move reply form fields 1816 * Move reply form fields. 1861 1817 * 1862 1818 * Output the required hidden fields when moving a reply … … 1872 1828 1873 1829 /** 1874 * Output a textarea or TinyMCE if enabled 1830 * Output a textarea or TinyMCE if enabled. 1875 1831 * 1876 1832 * @since 2.1.0 bbPress (r3586) … … 1881 1837 echo bbp_get_the_content( $args ); 1882 1838 } 1883 /** 1884 * Return a textarea or TinyMCE if enabled 1839 1840 /** 1841 * Return a textarea or TinyMCE if enabled. 1842 * 1843 * @since 2.1.0 bbPress (r3586) 1844 * 1845 * @param array $args 1846 * 1847 * @return string HTML from output buffer 1848 */ 1849 function bbp_get_the_content( $args = array() ) { 1850 1851 // Parse arguments against default values 1852 $r = bbp_parse_args( $args, array( 1853 'context' => 'topic', 1854 'before' => '<div class="bbp-the-content-wrapper">', 1855 'after' => '</div>', 1856 'wpautop' => true, 1857 'media_buttons' => false, 1858 'textarea_rows' => '12', 1859 'tabindex' => false, 1860 'tabfocus_elements' => 'bbp_topic_title,bbp_topic_tags', 1861 'editor_class' => 'bbp-the-content', 1862 'tinymce' => false, 1863 'teeny' => true, 1864 'quicktags' => true, 1865 'dfw' => false, 1866 ), 'get_the_content' ); 1867 1868 // If using tinymce, remove our escaping and trust tinymce 1869 if ( bbp_use_wp_editor() && ( false !== $r['tinymce'] ) ) { 1870 remove_filter( 'bbp_get_form_forum_content', 'esc_textarea' ); 1871 remove_filter( 'bbp_get_form_topic_content', 'esc_textarea' ); 1872 remove_filter( 'bbp_get_form_reply_content', 'esc_textarea' ); 1873 } 1874 1875 // Assume we are not editing 1876 $post_content = call_user_func( 'bbp_get_form_' . $r['context']. '_content' ); 1877 1878 // Start an output buffor 1879 ob_start(); 1880 1881 // Output something before the editor 1882 if ( ! empty( $r['before'] ) ) { 1883 echo $r['before']; 1884 } 1885 1886 // Use TinyMCE if available 1887 if ( bbp_use_wp_editor() ) { 1888 1889 // Enable additional TinyMCE plugins before outputting the editor 1890 add_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); 1891 add_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); 1892 add_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' ); 1893 add_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' ); 1894 1895 // Output the editor 1896 wp_editor( $post_content, 'bbp_' . $r['context']. '_content', array( 1897 'wpautop' => $r['wpautop'], 1898 'media_buttons' => $r['media_buttons'], 1899 'textarea_rows' => $r['textarea_rows'], 1900 'tabindex' => $r['tabindex'], 1901 'tabfocus_elements' => $r['tabfocus_elements'], 1902 'editor_class' => $r['editor_class'], 1903 'tinymce' => $r['tinymce'], 1904 'teeny' => $r['teeny'], 1905 'quicktags' => $r['quicktags'], 1906 'dfw' => $r['dfw'], 1907 ) ); 1908 1909 // Remove additional TinyMCE plugins after outputting the editor 1910 remove_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); 1911 remove_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); 1912 remove_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' ); 1913 remove_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' ); 1914 1915 /* 1916 * Fallback to normal textarea. 1885 1917 * 1886 * @since 2.1.0 bbPress (r3586) 1887 * 1888 * @param array $args 1889 * 1890 * @return string HTML from output buffer 1918 * Note that we do not use esc_textarea() here to prevent double 1919 * escaping the editable output, mucking up existing content. 1891 1920 */ 1892 function bbp_get_the_content( $args = array() ) { 1893 1894 // Parse arguments against default values 1895 $r = bbp_parse_args( $args, array( 1896 'context' => 'topic', 1897 'before' => '<div class="bbp-the-content-wrapper">', 1898 'after' => '</div>', 1899 'wpautop' => true, 1900 'media_buttons' => false, 1901 'textarea_rows' => '12', 1902 'tabindex' => false, 1903 'tabfocus_elements' => 'bbp_topic_title,bbp_topic_tags', 1904 'editor_class' => 'bbp-the-content', 1905 'tinymce' => false, 1906 'teeny' => true, 1907 'quicktags' => true, 1908 'dfw' => false 1909 ), 'get_the_content' ); 1910 1911 // If using tinymce, remove our escaping and trust tinymce 1912 if ( bbp_use_wp_editor() && ( false !== $r['tinymce'] ) ) { 1913 remove_filter( 'bbp_get_form_forum_content', 'esc_textarea' ); 1914 remove_filter( 'bbp_get_form_topic_content', 'esc_textarea' ); 1915 remove_filter( 'bbp_get_form_reply_content', 'esc_textarea' ); 1916 } 1917 1918 // Assume we are not editing 1919 $post_content = call_user_func( 'bbp_get_form_' . $r['context'] . '_content' ); 1920 1921 // Start an output buffor 1922 ob_start(); 1923 1924 // Output something before the editor 1925 if ( ! empty( $r['before'] ) ) { 1926 echo $r['before']; 1927 } 1928 1929 // Use TinyMCE if available 1930 if ( bbp_use_wp_editor() ) : 1931 1932 // Enable additional TinyMCE plugins before outputting the editor 1933 add_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); 1934 add_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); 1935 add_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' ); 1936 add_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' ); 1937 1938 // Output the editor 1939 wp_editor( $post_content, 'bbp_' . $r['context'] . '_content', array( 1940 'wpautop' => $r['wpautop'], 1941 'media_buttons' => $r['media_buttons'], 1942 'textarea_rows' => $r['textarea_rows'], 1943 'tabindex' => $r['tabindex'], 1944 'tabfocus_elements' => $r['tabfocus_elements'], 1945 'editor_class' => $r['editor_class'], 1946 'tinymce' => $r['tinymce'], 1947 'teeny' => $r['teeny'], 1948 'quicktags' => $r['quicktags'], 1949 'dfw' => $r['dfw'], 1950 ) ); 1951 1952 // Remove additional TinyMCE plugins after outputting the editor 1953 remove_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); 1954 remove_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' ); 1955 remove_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' ); 1956 remove_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' ); 1957 1958 /** 1959 * Fallback to normal textarea. 1960 * 1961 * Note that we do not use esc_textarea() here to prevent double 1962 * escaping the editable output, mucking up existing content. 1963 */ 1964 else : ?> 1965 1966 <textarea id="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" class="<?php echo esc_attr( $r['editor_class'] ); ?>" name="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" cols="60" rows="<?php echo esc_attr( $r['textarea_rows'] ); ?>" <?php bbp_tab_index_attribute( $r['tabindex'] ); ?>><?php echo $post_content; ?></textarea> 1967 1968 <?php endif; 1969 1970 // Output something after the editor 1971 if ( ! empty( $r['after'] ) ) { 1972 echo $r['after']; 1973 } 1974 1975 // Put the output into a usable variable 1976 $output = ob_get_clean(); 1977 1978 // Filter & return 1979 return apply_filters( 'bbp_get_the_content', $output, $args, $post_content ); 1980 } 1981 1982 /** 1983 * Edit TinyMCE plugins to match core behaviour 1921 } else { ?> 1922 1923 <textarea id="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" class="<?php echo esc_attr( $r['editor_class'] ); ?>" name="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" cols="60" rows="<?php echo esc_attr( $r['textarea_rows'] ); ?>" <?php bbp_tab_index_attribute( $r['tabindex'] ); ?>><?php echo $post_content; ?></textarea> 1924 1925 <?php } 1926 1927 // Output something after the editor 1928 if ( ! empty( $r['after'] ) ) { 1929 echo $r['after']; 1930 } 1931 1932 // Put the output into a usable variable 1933 $output = ob_get_clean(); 1934 1935 // Filter & return 1936 return apply_filters( 'bbp_get_the_content', $output, $args, $post_content ); 1937 } 1938 1939 /** 1940 * Edit TinyMCE plugins to match core behaviour. 1984 1941 * 1985 1942 * @since 2.3.0 bbPress (r4574) 1986 1943 * 1987 1944 * @param array $plugins 1945 * 1988 1946 * @see tiny_mce_plugins, teeny_mce_plugins 1947 * 1989 1948 * @return array 1990 1949 */ … … 2007 1966 2008 1967 /** 2009 * Edit TeenyMCE buttons to match allowedtags 1968 * Edit TeenyMCE buttons to match allowedtags. 2010 1969 * 2011 1970 * @since 2.3.0 bbPress (r4605) 2012 1971 * 2013 1972 * @param array $buttons 1973 * 2014 1974 * @see teeny_mce_buttons 1975 * 2015 1976 * @return array 2016 1977 */ … … 2022 1983 'justifyleft', 2023 1984 'justifycenter', 2024 'justifyright' 1985 'justifyright', 2025 1986 ) ); 2026 1987 … … 2033 1994 2034 1995 /** 2035 * Edit TinyMCE quicktags buttons to match allowedtags 1996 * Edit TinyMCE quicktags buttons to match allowedtags. 2036 1997 * 2037 1998 * @since 2.3.0 bbPress (r4606) 2038 1999 * 2039 2000 * @param array $settings 2001 * 2040 2002 * @see quicktags_settings 2003 * 2041 2004 * @return array Quicktags settings 2042 2005 */ … … 2050 2013 'ins', 2051 2014 'more', 2052 'spell' 2015 'spell', 2053 2016 ) ); 2054 2017 … … 2063 2026 2064 2027 /** 2065 * Output the view id 2028 * Output the view id. 2066 2029 * 2067 2030 * @since 2.0.0 bbPress (r2789) … … 2073 2036 } 2074 2037 2075 /** 2076 * Get the view id 2077 * 2078 * Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var. 2079 * 2080 * @since 2.0.0 bbPress (r2789) 2081 * 2082 * @param string $view Optional. View id. 2083 * @return bool|string ID on success, false on failure 2084 */ 2085 function bbp_get_view_id( $view = '' ) { 2086 $bbp = bbpress(); 2087 2088 // User supplied string 2089 if ( ! empty( $view ) && is_string( $view ) ) { 2090 $view_id = $view; 2091 2092 // Current view ID 2093 } elseif ( ! empty( $bbp->current_view_id ) ) { 2094 $view_id = $bbp->current_view_id; 2095 2096 // Querying for view 2097 } else { 2098 $view_id = get_query_var( bbp_get_view_rewrite_id() ); 2099 } 2100 2101 // Filter & return 2102 return apply_filters( 'bbp_get_view_id', $view_id, $view ); 2103 } 2104 2105 /** 2106 * Output the view name aka title 2038 /** 2039 * Get the view id. 2040 * 2041 * Use view id if supplied, otherwise bbp_get_view_rewrite_id() query var. 2042 * 2043 * @since 2.0.0 bbPress (r2789) 2044 * 2045 * @param string $view Optional. View id. 2046 * 2047 * @return bool|string ID on success, false on failure 2048 */ 2049 function bbp_get_view_id( $view = '' ) { 2050 $bbp = bbpress(); 2051 2052 // User supplied string 2053 if ( ! empty( $view ) && is_string( $view ) ) { 2054 $view_id = $view; 2055 2056 // Current view ID 2057 } elseif ( ! empty( $bbp->current_view_id ) ) { 2058 $view_id = $bbp->current_view_id; 2059 2060 // Querying for view 2061 } else { 2062 $view_id = get_query_var( bbp_get_view_rewrite_id() ); 2063 } 2064 2065 // Filter & return 2066 return apply_filters( 'bbp_get_view_id', $view_id, $view ); 2067 } 2068 2069 /** 2070 * Output the view name aka title. 2107 2071 * 2108 2072 * @since 2.0.0 bbPress (r2789) … … 2114 2078 } 2115 2079 2116 /** 2117 * Get the view name aka title 2118 * 2119 * If a view id is supplied, that is used. Otherwise the bbp_view 2120 * query var is checked for. 2121 * 2122 * @since 2.0.0 bbPress (r2789) 2123 * 2124 * @param string $view Optional. View id 2125 * @return bool|string Title on success, false on failure 2126 */ 2127 function bbp_get_view_title( $view = '' ) { 2128 $bbp = bbpress(); 2129 2130 $view = bbp_get_view_id( $view ); 2131 if ( empty( $view ) ) { 2132 return false; 2133 } 2134 2135 return $bbp->views[ $view ]['title']; 2136 } 2137 2138 /** 2139 * Output the view url 2080 /** 2081 * Get the view name aka title. 2082 * 2083 * If a view id is supplied, that is used. Otherwise the bbp_view 2084 * query var is checked for. 2085 * 2086 * @since 2.0.0 bbPress (r2789) 2087 * 2088 * @param string $view Optional. View id 2089 * 2090 * @return bool|string Title on success, false on failure 2091 */ 2092 function bbp_get_view_title( $view = '' ) { 2093 $bbp = bbpress(); 2094 2095 $view = bbp_get_view_id( $view ); 2096 if ( empty( $view ) ) { 2097 return false; 2098 } 2099 2100 return $bbp->views[ $view ]['title']; 2101 } 2102 2103 /** 2104 * Output the view url. 2140 2105 * 2141 2106 * @since 2.0.0 bbPress (r2789) … … 2146 2111 echo esc_url( bbp_get_view_url( $view ) ); 2147 2112 } 2148 /**2149 * Return the view url 2150 *2151 * @since 2.0.0 bbPress (r2789)2152 *2153 * @param string $view Optional. View id2154 *used view id2155 * @return string View url (or home url if the view was not found) 2156 */ 2157 function bbp_get_view_url( $view = false ) { 2158 2159 $view = bbp_get_view_id( $view ); 2160 if ( empty( $view ) ) {2161 return home_url();2162 }2163 2164 // Pretty permalinks 2165 if ( bbp_use_pretty_urls() ) {2166 2167 // Run through home_url()2168 $url = trailingslashit( bbp_get_root_url() . bbp_get_view_slug() ) . $view;2169 $url = user_trailingslashit( $url );2170 $url = home_url( $url );2171 2172 // Unpretty permalinks2173 } else {2174 $url = add_query_arg( array(2175 bbp_get_view_rewrite_id() => $view2176 ), home_url( '/' ) );2177 }2178 2179 // Filter & return2180 return apply_filters( 'bbp_get_view_link', $url, $view );2181 }2113 /** 2114 * Return the view url. 2115 * 2116 * @since 2.0.0 bbPress (r2789) 2117 * 2118 * @param string $view Optional. View id 2119 * used view id 2120 * 2121 * @return string View url (or home url if the view was not found ) 2122 */ 2123 function bbp_get_view_url( $view = false ) { 2124 2125 $view = bbp_get_view_id( $view ); 2126 if ( empty( $view ) ) { 2127 return home_url(); 2128 } 2129 2130 // Pretty permalinks 2131 if ( bbp_use_pretty_urls() ) { 2132 // Run through home_url() 2133 $url = trailingslashit( bbp_get_root_url() . bbp_get_view_slug() ) . $view; 2134 $url = user_trailingslashit( $url ); 2135 $url = home_url( $url ); 2136 2137 // Unpretty permalinks 2138 } else { 2139 $url = add_query_arg( array( 2140 bbp_get_view_rewrite_id() => $view, 2141 ), home_url( '/' ) ); 2142 } 2143 2144 // Filter & return 2145 return apply_filters( 'bbp_get_view_link', $url, $view ); 2146 } 2182 2147 2183 2148 /** Query *********************************************************************/ 2184 2149 2185 2150 /** 2186 * Check the passed parameter against the current _bbp_query_name 2151 * Check the passed parameter against the current _bbp_query_name. 2187 2152 * 2188 2153 * @since 2.0.0 bbPress (r2980) … … 2195 2160 2196 2161 /** 2197 * Get the '_bbp_query_name' setting 2162 * Get the '_bbp_query_name' setting. 2198 2163 * 2199 2164 * @since 2.0.0 bbPress (r2695) … … 2206 2171 2207 2172 /** 2208 * Set the '_bbp_query_name' setting to $name 2173 * Set the '_bbp_query_name' setting to $name. 2209 2174 * 2210 2175 * @since 2.0.0 bbPress (r2692) … … 2217 2182 2218 2183 /** 2219 * Used to clear the '_bbp_query_name' setting 2184 * Used to clear the '_bbp_query_name' setting. 2220 2185 * 2221 2186 * @since 2.0.0 bbPress (r2692) 2222 *2223 2187 */ 2224 2188 function bbp_reset_query_name() { … … 2229 2193 2230 2194 /** 2231 * Output the page title as a breadcrumb 2195 * Output the page title as a breadcrumb. 2196 * 2197 * @since 2.0.0 bbPress (r2589) 2198 */ 2199 function bbp_title_breadcrumb( $args = array() ) { 2200 echo bbp_get_breadcrumb( $args ); 2201 } 2202 2203 /** 2204 * Output a breadcrumb. 2205 * 2206 * @since 2.0.0 bbPress (r2589) 2207 */ 2208 function bbp_breadcrumb( $args = array() ) { 2209 echo bbp_get_breadcrumb( $args ); 2210 } 2211 2212 /** 2213 * Return a breadcrumb ( forum -> topic -> reply ) 2232 2214 * 2233 2215 * @since 2.0.0 bbPress (r2589) … … 2236 2218 * @param bool $current_page Include the current item 2237 2219 * @param bool $root Include the root page if one exists 2238 */ 2239 function bbp_title_breadcrumb( $args = array() ) { 2240 echo bbp_get_breadcrumb( $args ); 2241 } 2242 2243 /** 2244 * Output a breadcrumb 2245 * 2246 * @since 2.0.0 bbPress (r2589) 2247 * 2248 * @param string $sep Separator. Defaults to '←' 2249 * @param bool $current_page Include the current item 2250 * @param bool $root Include the root page if one exists 2251 */ 2252 function bbp_breadcrumb( $args = array() ) { 2253 echo bbp_get_breadcrumb( $args ); 2254 } 2255 /** 2256 * Return a breadcrumb ( forum -> topic -> reply ) 2257 * 2258 * @since 2.0.0 bbPress (r2589) 2259 * 2260 * @param string $sep Separator. Defaults to '←' 2261 * @param bool $current_page Include the current item 2262 * @param bool $root Include the root page if one exists 2263 * 2264 * @return string Breadcrumbs 2265 */ 2266 function bbp_get_breadcrumb( $args = array() ) { 2267 2268 // Turn off breadcrumbs 2269 if ( apply_filters( 'bbp_no_breadcrumb', is_front_page() ) ) { 2270 return; 2220 * 2221 * @return string Breadcrumbs 2222 */ 2223 function bbp_get_breadcrumb( $args = array() ) { 2224 2225 // Turn off breadcrumbs 2226 if ( apply_filters( 'bbp_no_breadcrumb', is_front_page() ) ) { 2227 return; 2228 } 2229 2230 // Define variables 2231 $front_id = $root_id = $remove_root_id = 0; 2232 $ancestors = $crumbs = $tag_data = array(); 2233 $pre_root_text = $pre_front_text = $pre_current_text = ''; 2234 $pre_include_root = $pre_include_home = $pre_include_current = true; 2235 2236 /** Home Text *************************************************************/ 2237 2238 // No custom home text 2239 if ( empty( $args['home_text'] ) ) { 2240 2241 $front_id = get_option( 'page_on_front' ); 2242 2243 // Set home text to page title 2244 if ( ! empty( $front_id ) ) { 2245 $pre_front_text = get_the_title( $front_id ); 2246 2247 // Default to 'Home' 2248 } else { 2249 $pre_front_text = esc_html__( 'Home', 'bbpress' ); 2271 2250 } 2272 2273 // Define variables 2274 $front_id = $root_id = $remove_root_id = 0; 2275 $ancestors = $crumbs = $tag_data = array(); 2276 $pre_root_text = $pre_front_text = $pre_current_text = ''; 2277 $pre_include_root = $pre_include_home = $pre_include_current = true; 2278 2279 /** Home Text *********************************************************/ 2280 2281 // No custom home text 2282 if ( empty( $args['home_text'] ) ) { 2283 2284 $front_id = get_option( 'page_on_front' ); 2285 2286 // Set home text to page title 2287 if ( ! empty( $front_id ) ) { 2288 $pre_front_text = get_the_title( $front_id ); 2289 2290 // Default to 'Home' 2291 } else { 2292 $pre_front_text = esc_html__( 'Home', 'bbpress' ); 2251 } 2252 2253 /** Root Text *************************************************************/ 2254 2255 // No custom root text 2256 if ( empty( $args['root_text'] ) ) { 2257 $page = bbp_get_page_by_path( bbp_get_root_slug() ); 2258 if ( ! empty( $page ) ) { 2259 $root_id = $page->ID; 2260 } 2261 $pre_root_text = bbp_get_forum_archive_title(); 2262 } 2263 2264 /** Includes **************************************************************/ 2265 2266 // Root slug is also the front page 2267 if ( ! empty( $front_id ) && ( $front_id === $root_id ) ) { 2268 $pre_include_root = false; 2269 } 2270 2271 // Don't show root if viewing forum archive 2272 if ( bbp_is_forum_archive() ) { 2273 $pre_include_root = false; 2274 } 2275 2276 // Don't show root if viewing page in place of forum archive 2277 if ( ! empty( $root_id ) && ( ( is_single() || is_page() ) && ( get_the_ID() === $root_id ) ) ) { 2278 $pre_include_root = false; 2279 } 2280 2281 /** Current Text **********************************************************/ 2282 2283 // Search page 2284 if ( bbp_is_search() ) { 2285 $pre_current_text = bbp_get_search_title(); 2286 2287 // Forum archive 2288 } elseif ( bbp_is_forum_archive() ) { 2289 $pre_current_text = bbp_get_forum_archive_title(); 2290 2291 // Topic archive 2292 } elseif ( bbp_is_topic_archive() ) { 2293 $pre_current_text = bbp_get_topic_archive_title(); 2294 2295 // View 2296 } elseif ( bbp_is_single_view() ) { 2297 $pre_current_text = bbp_get_view_title(); 2298 2299 // Single Forum 2300 } elseif ( bbp_is_single_forum() ) { 2301 $pre_current_text = bbp_get_forum_title(); 2302 2303 // Single Topic 2304 } elseif ( bbp_is_single_topic() ) { 2305 $pre_current_text = bbp_get_topic_title(); 2306 2307 // Single Topic 2308 } elseif ( bbp_is_single_reply() ) { 2309 $pre_current_text = bbp_get_reply_title(); 2310 2311 // Topic Tag (or theme compat topic tag) 2312 } elseif ( bbp_is_topic_tag() || ( get_query_var( 'bbp_topic_tag' ) && ! bbp_is_topic_tag_edit() ) ) { 2313 2314 // Always include the tag name 2315 $tag_data[] = bbp_get_topic_tag_name(); 2316 2317 // If capable, include a link to edit the tag 2318 if ( current_user_can( 'manage_topic_tags' ) ) { 2319 $tag_data[] = '<a href="' . esc_url( bbp_get_topic_tag_edit_link() ) . '" class="bbp-edit-topic-tag-link">' . esc_html__( '(Edit)', 'bbpress' ) . '</a>'; 2320 } 2321 2322 // Implode the results of the tag data 2323 /* translators: %s: Topic tag data */ 2324 $pre_current_text = sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), implode( ' ', $tag_data ) ); 2325 2326 // Edit Topic Tag 2327 } elseif ( bbp_is_topic_tag_edit() ) { 2328 $pre_current_text = esc_html__( 'Edit', 'bbpress' ); 2329 2330 // Single 2331 } else { 2332 $pre_current_text = get_the_title(); 2333 } 2334 2335 /** Parse Args ************************************************************/ 2336 2337 // Parse args 2338 $r = bbp_parse_args( $args, array( 2339 2340 // HTML 2341 'before' => '<div class="bbp-breadcrumb"><p>', 2342 'after' => '</p></div>', 2343 2344 // Separator 2345 'sep' => is_rtl() ? __( '‹', 'bbpress' ) : __( '›', 'bbpress' ), 2346 'pad_sep' => 1, 2347 'sep_before' => '<span class="bbp-breadcrumb-sep">', 2348 'sep_after' => '</span>', 2349 2350 // Crumbs 2351 'crumb_before' => '', 2352 'crumb_after' => '', 2353 2354 // Home 2355 'include_home' => $pre_include_home, 2356 'home_text' => $pre_front_text, 2357 2358 // Forum root 2359 'include_root' => $pre_include_root, 2360 'root_text' => $pre_root_text, 2361 2362 // Current 2363 'include_current' => $pre_include_current, 2364 'current_text' => $pre_current_text, 2365 'current_before' => '<span class="bbp-breadcrumb-current">', 2366 'current_after' => '</span>', 2367 ), 'get_breadcrumb' ); 2368 2369 /** Ancestors *********************************************************/ 2370 2371 // Get post ancestors 2372 if ( is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() ) { 2373 $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) ); 2374 } 2375 2376 // Do we want to include a link to home? 2377 if ( ! empty( $r['include_home'] ) || empty( $r['home_text'] ) ) { 2378 $crumbs[] = '<a href="' . esc_url( home_url() ) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>'; 2379 } 2380 2381 // Do we want to include a link to the forum root? 2382 if ( ! empty( $r['include_root'] ) || empty( $r['root_text'] ) ) { 2383 2384 // Page exists at root slug path, so use its permalink 2385 $page = bbp_get_page_by_path( bbp_get_root_slug() ); 2386 if ( ! empty( $page ) ) { 2387 $root_url = get_permalink( $page->ID ); 2388 $remove_root_id = $page->ID; 2389 2390 // Use the root slug 2391 } else { 2392 $root_url = get_post_type_archive_link( bbp_get_forum_post_type() ); 2393 } 2394 2395 // Add the breadcrumb 2396 $crumbs[] = '<a href="' . esc_url( $root_url ) . '" class="bbp-breadcrumb-root">' . $r['root_text'] . '</a>'; 2397 } 2398 2399 // Ancestors exist 2400 if ( ! empty( $ancestors ) ) { 2401 2402 // Loop through parents 2403 foreach ( (array) $ancestors as $parent_id ) { 2404 2405 // Parents 2406 $parent = get_post( $parent_id ); 2407 2408 // Skip parent if empty or error 2409 if ( empty( $parent ) || is_wp_error( $parent ) ) { 2410 continue; 2411 } 2412 2413 // Skip to prevent duplicate root on subpages 2414 if ( ! empty( $remove_root_id ) && ( $parent->ID === $remove_root_id ) ) { 2415 continue; 2416 } 2417 2418 // Switch through post_type to ensure correct filters are applied 2419 switch ( $parent->post_type ) { 2420 2421 // Forum 2422 case bbp_get_forum_post_type() : 2423 $crumbs[] = '<a href="' . esc_url( bbp_get_forum_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $parent->ID ) . '</a>'; 2424 break; 2425 2426 // Topic 2427 case bbp_get_topic_post_type() : 2428 $crumbs[] = '<a href="' . esc_url( bbp_get_topic_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title( $parent->ID ) . '</a>'; 2429 break; 2430 2431 // Reply (Note: not in most themes ) 2432 case bbp_get_reply_post_type() : 2433 $crumbs[] = '<a href="' . esc_url( bbp_get_reply_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title( $parent->ID ) . '</a>'; 2434 break; 2435 2436 // WordPress Post/Page/Other 2437 default : 2438 $crumbs[] = '<a href="' . esc_url( get_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-item">' . get_the_title( $parent->ID ) . '</a>'; 2439 break; 2293 2440 } 2294 2441 } 2295 2442 2296 /** Root Text *********************************************************/ 2297 2298 // No custom root text 2299 if ( empty( $args['root_text'] ) ) { 2300 $page = bbp_get_page_by_path( bbp_get_root_slug() ); 2301 if ( ! empty( $page ) ) { 2302 $root_id = $page->ID; 2303 } 2304 $pre_root_text = bbp_get_forum_archive_title(); 2443 // Edit topic tag 2444 } elseif ( bbp_is_topic_tag_edit() ) { 2445 /* translators: %s: Topic Tag name */ 2446 $crumbs[] = '<a href="' . esc_url( get_term_link( bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id() ) ) . '" class="bbp-breadcrumb-topic-tag">' . sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ) . '</a>'; 2447 2448 // Search 2449 } elseif ( bbp_is_search() && bbp_get_search_terms() ) { 2450 $crumbs[] = '<a href="' . esc_url( bbp_get_search_url() ) . '" class="bbp-breadcrumb-search">' . esc_html__( 'Search', 'bbpress' ) . '</a>'; 2451 } 2452 2453 /** Current ***********************************************************/ 2454 2455 // Add current page to breadcrumb 2456 if ( ! empty( $r['include_current'] ) || empty( $r['current_text'] ) ) { 2457 $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after']; 2458 } 2459 2460 /** Separator *********************************************************/ 2461 2462 // Wrap the separator in before/after before padding and filter 2463 if ( ! empty( $r['sep'] ) ) { 2464 $sep = $r['sep_before'] . $r['sep'] . $r['sep_after']; 2465 } else { 2466 $sep = ''; 2467 } 2468 2469 // Pad the separator 2470 if ( ! empty( $r['pad_sep'] ) ) { 2471 if ( function_exists( 'mb_strlen' ) ) { 2472 $sep = str_pad( $sep, mb_strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH ); 2473 } else { 2474 $sep = str_pad( $sep, strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH ); 2305 2475 } 2306 2307 /** Includes **********************************************************/ 2308 2309 // Root slug is also the front page 2310 if ( ! empty( $front_id ) && ( $front_id === $root_id ) ) { 2311 $pre_include_root = false; 2312 } 2313 2314 // Don't show root if viewing forum archive 2315 if ( bbp_is_forum_archive() ) { 2316 $pre_include_root = false; 2317 } 2318 2319 // Don't show root if viewing page in place of forum archive 2320 if ( ! empty( $root_id ) && ( ( is_single() || is_page() ) && ( get_the_ID() === $root_id ) ) ) { 2321 $pre_include_root = false; 2322 } 2323 2324 /** Current Text ******************************************************/ 2325 2326 // Search page 2327 if ( bbp_is_search() ) { 2328 $pre_current_text = bbp_get_search_title(); 2329 2330 // Forum archive 2331 } elseif ( bbp_is_forum_archive() ) { 2332 $pre_current_text = bbp_get_forum_archive_title(); 2333 2334 // Topic archive 2335 } elseif ( bbp_is_topic_archive() ) { 2336 $pre_current_text = bbp_get_topic_archive_title(); 2337 2338 // View 2339 } elseif ( bbp_is_single_view() ) { 2340 $pre_current_text = bbp_get_view_title(); 2341 2342 // Single Forum 2343 } elseif ( bbp_is_single_forum() ) { 2344 $pre_current_text = bbp_get_forum_title(); 2345 2346 // Single Topic 2347 } elseif ( bbp_is_single_topic() ) { 2348 $pre_current_text = bbp_get_topic_title(); 2349 2350 // Single Topic 2351 } elseif ( bbp_is_single_reply() ) { 2352 $pre_current_text = bbp_get_reply_title(); 2353 2354 // Topic Tag (or theme compat topic tag) 2355 } elseif ( bbp_is_topic_tag() || ( get_query_var( 'bbp_topic_tag' ) && ! bbp_is_topic_tag_edit() ) ) { 2356 2357 // Always include the tag name 2358 $tag_data[] = bbp_get_topic_tag_name(); 2359 2360 // If capable, include a link to edit the tag 2361 if ( current_user_can( 'manage_topic_tags' ) ) { 2362 $tag_data[] = '<a href="' . esc_url( bbp_get_topic_tag_edit_link() ) . '" class="bbp-edit-topic-tag-link">' . esc_html__( '(Edit)', 'bbpress' ) . '</a>'; 2363 } 2364 2365 // Implode the results of the tag data 2366 $pre_current_text = sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), implode( ' ', $tag_data ) ); 2367 2368 // Edit Topic Tag 2369 } elseif ( bbp_is_topic_tag_edit() ) { 2370 $pre_current_text = esc_html__( 'Edit', 'bbpress' ); 2371 2372 // Single 2373 } else { 2374 $pre_current_text = get_the_title(); 2375 } 2376 2377 /** Parse Args ********************************************************/ 2378 2379 // Parse args 2380 $r = bbp_parse_args( $args, array( 2381 2382 // HTML 2383 'before' => '<div class="bbp-breadcrumb"><p>', 2384 'after' => '</p></div>', 2385 2386 // Separator 2387 'sep' => is_rtl() ? __( '‹', 'bbpress' ) : __( '›', 'bbpress' ), 2388 'pad_sep' => 1, 2389 'sep_before' => '<span class="bbp-breadcrumb-sep">', 2390 'sep_after' => '</span>', 2391 2392 // Crumbs 2393 'crumb_before' => '', 2394 'crumb_after' => '', 2395 2396 // Home 2397 'include_home' => $pre_include_home, 2398 'home_text' => $pre_front_text, 2399 2400 // Forum root 2401 'include_root' => $pre_include_root, 2402 'root_text' => $pre_root_text, 2403 2404 // Current 2405 'include_current' => $pre_include_current, 2406 'current_text' => $pre_current_text, 2407 'current_before' => '<span class="bbp-breadcrumb-current">', 2408 'current_after' => '</span>', 2409 ), 'get_breadcrumb' ); 2410 2411 /** Ancestors *********************************************************/ 2412 2413 // Get post ancestors 2414 if ( is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() ) { 2415 $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) ); 2416 } 2417 2418 // Do we want to include a link to home? 2419 if ( ! empty( $r['include_home'] ) || empty( $r['home_text'] ) ) { 2420 $crumbs[] = '<a href="' . esc_url( home_url() ) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>'; 2421 } 2422 2423 // Do we want to include a link to the forum root? 2424 if ( ! empty( $r['include_root'] ) || empty( $r['root_text'] ) ) { 2425 2426 // Page exists at root slug path, so use its permalink 2427 $page = bbp_get_page_by_path( bbp_get_root_slug() ); 2428 if ( ! empty( $page ) ) { 2429 $root_url = get_permalink( $page->ID ); 2430 $remove_root_id = $page->ID; 2431 2432 // Use the root slug 2433 } else { 2434 $root_url = get_post_type_archive_link( bbp_get_forum_post_type() ); 2435 } 2436 2437 // Add the breadcrumb 2438 $crumbs[] = '<a href="' . esc_url( $root_url ) . '" class="bbp-breadcrumb-root">' . $r['root_text'] . '</a>'; 2439 } 2440 2441 // Ancestors exist 2442 if ( ! empty( $ancestors ) ) { 2443 2444 // Loop through parents 2445 foreach ( (array) $ancestors as $parent_id ) { 2446 2447 // Parents 2448 $parent = get_post( $parent_id ); 2449 2450 // Skip parent if empty or error 2451 if ( empty( $parent ) || is_wp_error( $parent ) ) { 2452 continue; 2453 } 2454 2455 // Skip to prevent duplicate root on subpages 2456 if ( ! empty( $remove_root_id ) && ( $parent->ID === $remove_root_id ) ) { 2457 continue; 2458 } 2459 2460 // Switch through post_type to ensure correct filters are applied 2461 switch ( $parent->post_type ) { 2462 2463 // Forum 2464 case bbp_get_forum_post_type() : 2465 $crumbs[] = '<a href="' . esc_url( bbp_get_forum_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $parent->ID ) . '</a>'; 2466 break; 2467 2468 // Topic 2469 case bbp_get_topic_post_type() : 2470 $crumbs[] = '<a href="' . esc_url( bbp_get_topic_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title( $parent->ID ) . '</a>'; 2471 break; 2472 2473 // Reply (Note: not in most themes) 2474 case bbp_get_reply_post_type() : 2475 $crumbs[] = '<a href="' . esc_url( bbp_get_reply_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title( $parent->ID ) . '</a>'; 2476 break; 2477 2478 // WordPress Post/Page/Other 2479 default : 2480 $crumbs[] = '<a href="' . esc_url( get_permalink( $parent->ID ) ) . '" class="bbp-breadcrumb-item">' . get_the_title( $parent->ID ) . '</a>'; 2481 break; 2482 } 2483 } 2484 2485 // Edit topic tag 2486 } elseif ( bbp_is_topic_tag_edit() ) { 2487 $crumbs[] = '<a href="' . esc_url( get_term_link( bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id() ) ) . '" class="bbp-breadcrumb-topic-tag">' . sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ) . '</a>'; 2488 2489 // Search 2490 } elseif ( bbp_is_search() && bbp_get_search_terms() ) { 2491 $crumbs[] = '<a href="' . esc_url( bbp_get_search_url() ) . '" class="bbp-breadcrumb-search">' . esc_html__( 'Search', 'bbpress' ) . '</a>'; 2492 } 2493 2494 /** Current ***********************************************************/ 2495 2496 // Add current page to breadcrumb 2497 if ( ! empty( $r['include_current'] ) || empty( $r['current_text'] ) ) { 2498 $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after']; 2499 } 2500 2501 /** Separator *********************************************************/ 2502 2503 // Wrap the separator in before/after before padding and filter 2504 if ( ! empty( $r['sep'] ) ) { 2505 $sep = $r['sep_before'] . $r['sep'] . $r['sep_after']; 2506 } else { 2507 $sep = ''; 2508 } 2509 2510 // Pad the separator 2511 if ( ! empty( $r['pad_sep'] ) ) { 2512 if ( function_exists( 'mb_strlen' ) ) { 2513 $sep = str_pad( $sep, mb_strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH ); 2514 } else { 2515 $sep = str_pad( $sep, strlen( $sep ) + ( (int) $r['pad_sep'] * 2 ), ' ', STR_PAD_BOTH ); 2476 } 2477 2478 /** Finish Up *********************************************************/ 2479 2480 // Filter the separator and breadcrumb 2481 $sep = apply_filters( 'bbp_breadcrumb_separator', $sep ); 2482 $crumbs = apply_filters( 'bbp_breadcrumbs', $crumbs ); 2483 2484 // Build the trail 2485 $trail = ! empty( $crumbs ) 2486 ? ( $r['before'] . $r['crumb_before'] . implode( $sep . $r['crumb_after'] . $r['crumb_before'], $crumbs ) . $r['crumb_after'] . $r['after'] ) 2487 : ''; 2488 2489 // Filter & return 2490 return apply_filters( 'bbp_get_breadcrumb', $trail, $crumbs, $r, $args ); 2491 } 2492 2493 /** Topic Tags ***************************************************************/ 2494 2495 /** 2496 * Output all of the allowed tags in HTML format with attributes. 2497 * 2498 * This is useful for displaying in the post area, which elements and 2499 * attributes are supported. As well as any plugins which want to display it. 2500 * 2501 * @since 2.0.0 bbPress (r2780) 2502 */ 2503 function bbp_allowed_tags() { 2504 echo bbp_get_allowed_tags(); 2505 } 2506 2507 /** 2508 * Display all of the allowed tags in HTML format with attributes. 2509 * 2510 * This is useful for displaying in the post area, which elements and 2511 * attributes are supported. As well as any plugins which want to display it. 2512 * 2513 * @since 2.0.0 bbPress (r2780) 2514 * 2515 * @return string HTML allowed tags entity encoded 2516 */ 2517 function bbp_get_allowed_tags() { 2518 $allowed = ''; 2519 2520 foreach ( (array) bbp_kses_allowed_tags() as $tag => $attributes ) { 2521 $allowed .= '<' . $tag; 2522 2523 if ( 0 < count( $attributes ) ) { 2524 foreach ( array_keys( $attributes ) as $attribute ) { 2525 $allowed .= ' ' . $attribute. '=""'; 2516 2526 } 2517 2527 } 2518 2528 2519 /** Finish Up *********************************************************/ 2520 2521 // Filter the separator and breadcrumb 2522 $sep = apply_filters( 'bbp_breadcrumb_separator', $sep ); 2523 $crumbs = apply_filters( 'bbp_breadcrumbs', $crumbs ); 2524 2525 // Build the trail 2526 $trail = ! empty( $crumbs ) ? ( $r['before'] . $r['crumb_before'] . implode( $sep . $r['crumb_after'] . $r['crumb_before'], $crumbs ) . $r['crumb_after'] . $r['after'] ) : ''; 2527 2528 // Filter & return 2529 return apply_filters( 'bbp_get_breadcrumb', $trail, $crumbs, $r, $args ); 2530 } 2531 2532 /** Topic Tags ***************************************************************/ 2533 2534 /** 2535 * Output all of the allowed tags in HTML format with attributes. 2536 * 2537 * This is useful for displaying in the post area, which elements and 2538 * attributes are supported. As well as any plugins which want to display it. 2539 * 2540 * @since 2.0.0 bbPress (r2780) 2541 */ 2542 function bbp_allowed_tags() { 2543 echo bbp_get_allowed_tags(); 2544 } 2545 /** 2546 * Display all of the allowed tags in HTML format with attributes. 2547 * 2548 * This is useful for displaying in the post area, which elements and 2549 * attributes are supported. As well as any plugins which want to display it. 2550 * 2551 * @since 2.0.0 bbPress (r2780) 2552 * 2553 * @return string HTML allowed tags entity encoded. 2554 */ 2555 function bbp_get_allowed_tags() { 2556 2557 $allowed = ''; 2558 2559 foreach ( (array) bbp_kses_allowed_tags() as $tag => $attributes ) { 2560 $allowed .= '<' . $tag; 2561 if ( 0 < count( $attributes ) ) { 2562 foreach ( array_keys( $attributes ) as $attribute ) { 2563 $allowed .= ' ' . $attribute . '=""'; 2564 } 2565 } 2566 $allowed .= '> '; 2567 } 2568 2569 // Filter & return 2570 return apply_filters( 'bbp_get_allowed_tags', htmlentities( $allowed ) ); 2571 } 2529 $allowed .= '> '; 2530 } 2531 2532 // Filter & return 2533 return apply_filters( 'bbp_get_allowed_tags', htmlentities( $allowed ) ); 2534 } 2572 2535 2573 2536 /** Errors & Messages *********************************************************/ 2574 2537 2575 2538 /** 2576 * Display possible errors & messages inside a template file 2539 * Display possible errors & messages inside a template file. 2577 2540 * 2578 2541 * @since 2.0.0 bbPress (r2688) … … 2585 2548 } 2586 2549 2587 // Define local variable(s )2550 // Define local variable(s ) 2588 2551 $errors = $messages = array(); 2589 2552 … … 2602 2565 $messages[] = $error; 2603 2566 } else { 2604 $errors[] = $error;2567 $errors[] = $error; 2605 2568 } 2606 2569 } … … 2608 2571 2609 2572 // Display errors first... 2610 if ( ! empty( $errors ) ) :?>2573 if ( ! empty( $errors ) ) { ?> 2611 2574 2612 2575 <div class="bbp-template-notice error" role="alert" tabindex="-1"> … … 2616 2579 </div> 2617 2580 2618 <?php endif;2581 <?php } 2619 2582 2620 2583 // ...and messages last 2621 if ( ! empty( $messages ) ) :?>2584 if ( ! empty( $messages ) ) { ?> 2622 2585 2623 2586 <div class="bbp-template-notice"> … … 2627 2590 </div> 2628 2591 2629 <?php endif; 2592 <?php 2593 2594 } 2630 2595 } 2631 2596 … … 2633 2598 2634 2599 /** 2635 * Output the logout link 2600 * Output the logout link. 2636 2601 * 2637 2602 * @since 2.0.0 bbPress (r2827) … … 2642 2607 echo bbp_get_logout_link( $redirect_to ); 2643 2608 } 2644 /** 2645 * Return the logout link 2646 * 2647 * @since 2.0.0 bbPress (r2827) 2648 * 2649 * @param string $redirect_to Redirect to url 2650 * redirect to url 2651 * @return string The logout link 2652 */ 2653 function bbp_get_logout_link( $redirect_to = '' ) { 2654 2655 // Build the link 2656 $link = '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ) . '</a>'; 2657 2658 // Filter & return 2659 return apply_filters( 'bbp_get_logout_link', $link, $redirect_to ); 2660 } 2609 2610 /** 2611 * Return the logout link. 2612 * 2613 * @since 2.0.0 bbPress (r2827) 2614 * 2615 * @param string $redirect_to Redirect to url 2616 * redirect to url 2617 * 2618 * @return string The logout link 2619 */ 2620 function bbp_get_logout_link( $redirect_to = '' ) { 2621 2622 // Build the link 2623 $link = '<a href="' . wp_logout_url( $redirect_to ). '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ). '</a>'; 2624 2625 // Filter & return 2626 return apply_filters( 'bbp_get_logout_link', $link, $redirect_to ); 2627 } 2661 2628 2662 2629 /** Title *********************************************************************/ 2663 2630 2664 2631 /** 2665 * Custom page title for bbPress pages 2632 * Custom page title for bbPress pages. 2666 2633 * 2667 2634 * @since 2.0.0 bbPress (r2788) 2668 2635 * 2669 * @param string $title Optional. The title (not used).2670 * @param string $sep Optional, default is '»'. How to separate the2671 * various items within the page title.2636 * @param string $title Optional. The title (not used ). 2637 * @param string $sep Optional, default is '»'. How to separate the 2638 * various items within the page title. 2672 2639 * @param string $seplocation Optional. Direction to display title, 'right'. 2673 * separator and separator location 2640 * separator and separator location 2641 * 2674 2642 * @return string The title 2675 2643 */ … … 2679 2647 $new_title = array(); 2680 2648 2681 /* * Archives **************************************************************/2649 /* Archives ************************************************************* */ 2682 2650 2683 2651 // Forum Archive … … 2689 2657 $new_title['text'] = bbp_get_topic_archive_title(); 2690 2658 2691 /* * Edit ******************************************************************/2659 /* Edit ***************************************************************** */ 2692 2660 2693 2661 // Forum edit page 2694 2662 } elseif ( bbp_is_forum_edit() ) { 2695 $new_title['text'] = bbp_get_forum_title(); 2663 $new_title['text'] = bbp_get_forum_title(); 2664 /* translators: %s: Forum title */ 2696 2665 $new_title['format'] = esc_attr__( 'Forum Edit: %s', 'bbpress' ); 2697 2666 2698 2667 // Topic edit page 2699 2668 } elseif ( bbp_is_topic_edit() ) { 2700 $new_title['text'] = bbp_get_topic_title(); 2669 $new_title['text'] = bbp_get_topic_title(); 2670 /* translators: %s: Topic title */ 2701 2671 $new_title['format'] = esc_attr__( 'Topic Edit: %s', 'bbpress' ); 2702 2672 2703 2673 // Reply edit page 2704 2674 } elseif ( bbp_is_reply_edit() ) { 2705 $new_title['text'] = bbp_get_reply_title(); 2675 $new_title['text'] = bbp_get_reply_title(); 2676 /* translators: %s: Reply title */ 2706 2677 $new_title['format'] = esc_attr__( 'Reply Edit: %s', 'bbpress' ); 2707 2678 2708 2679 // Topic tag edit page 2709 2680 } elseif ( bbp_is_topic_tag_edit() ) { 2710 $new_title['text'] = bbp_get_topic_tag_name(); 2681 $new_title['text'] = bbp_get_topic_tag_name(); 2682 /* translators: %s: Topic tag name */ 2711 2683 $new_title['format'] = esc_attr__( 'Topic Tag Edit: %s', 'bbpress' ); 2712 2684 2713 /* * Singles ***************************************************************/2685 /* Singles ************************************************************** */ 2714 2686 2715 2687 // Forum page 2716 2688 } elseif ( bbp_is_single_forum() ) { 2717 $new_title['text'] = bbp_get_forum_title(); 2689 $new_title['text'] = bbp_get_forum_title(); 2690 /* translators: %s: Forum title */ 2718 2691 $new_title['format'] = esc_attr__( 'Forum: %s', 'bbpress' ); 2719 2692 2720 2693 // Topic page 2721 2694 } elseif ( bbp_is_single_topic() ) { 2722 $new_title['text'] = bbp_get_topic_title(); 2695 $new_title['text'] = bbp_get_topic_title(); 2696 /* translators: %s: Topic title */ 2723 2697 $new_title['format'] = esc_attr__( 'Topic: %s', 'bbpress' ); 2724 2698 2725 2699 // Replies 2726 2700 } elseif ( bbp_is_single_reply() ) { 2727 $new_title['text'] = bbp_get_reply_title();2701 $new_title['text'] = bbp_get_reply_title(); 2728 2702 2729 2703 // Topic tag page 2730 2704 } elseif ( bbp_is_topic_tag() || get_query_var( 'bbp_topic_tag' ) ) { 2731 $new_title['text'] = bbp_get_topic_tag_name(); 2705 $new_title['text'] = bbp_get_topic_tag_name(); 2706 /* translators: %s: Topic tag name */ 2732 2707 $new_title['format'] = esc_attr__( 'Topic Tag: %s', 'bbpress' ); 2733 2708 2734 /* * Users *****************************************************************/2709 /* Users **************************************************************** */ 2735 2710 2736 2711 // Profile page 2737 2712 } elseif ( bbp_is_single_user() ) { 2738 2739 2713 // Is user viewing their own profile? 2740 2714 $is_user_home = bbp_is_user_home(); … … 2793 2767 // Profile edit page 2794 2768 } elseif ( bbp_is_single_user_edit() ) { 2795 2796 2769 // Current user 2797 2770 if ( bbp_is_user_home_edit() ) { 2798 $new_title['text'] = esc_attr__( 'Edit Your Profile', 'bbpress' );2771 $new_title['text'] = esc_attr__( 'Edit Your Profile', 'bbpress' ); 2799 2772 2800 2773 // Other user 2801 2774 } else { 2802 $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name; 2775 $new_title['text'] = get_userdata( bbp_get_user_id() )->display_name; 2776 /* translators: %s: User's display name */ 2803 2777 $new_title['format'] = esc_attr__( "Edit %s's Profile", 'bbpress' ); 2804 2778 } 2805 2779 2806 /* * Views *****************************************************************/2780 /* Views **************************************************************** */ 2807 2781 2808 2782 // Views 2809 2783 } elseif ( bbp_is_single_view() ) { 2810 $new_title['text'] = bbp_get_view_title(); 2784 $new_title['text'] = bbp_get_view_title(); 2785 /* translators: %s: View title */ 2811 2786 $new_title['format'] = esc_attr__( 'View: %s', 'bbpress' ); 2812 2787 2813 /* * Search ****************************************************************/2788 /* Search *************************************************************** */ 2814 2789 2815 2790 // Search … … 2824 2799 $new_title = bbp_parse_args( $new_title, array( 2825 2800 'text' => $title, 2826 'format' => '%s' 2801 'format' => '%s', 2827 2802 ), 'title' ); 2828 2803 … … 2872 2847 * @since 2.7.0 2873 2848 * 2874 * @param string $prepend Text displayed before a post title.2875 * @param int|WP_Post $post Current post object.2849 * @param string $prepend text displayed before a post title 2850 * @param int|WP_Post $post current post object 2876 2851 * 2877 2852 * @return string -
trunk/src/includes/common/widgets.php
r7357 r7360 803 803 <?php if ( ! empty( $author_link ) ) : ?> 804 804 805 <?php printf( esc_html_x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>' ); ?> 805 <?php 806 printf( 807 /* translators: %1$s: Topic author link wrapped in span tag */ 808 esc_html_x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>' 809 ); 810 ?> 806 811 807 812 <?php endif; ?> … … 1147 1152 if ( ! empty( $settings['show_date'] ) && ! empty( $author_link ) ) : 1148 1153 1149 / / translators: 1: reply author, 2: reply link, 3: reply timestamp1154 /* translators: 1: reply author, 2: reply link, 3: reply timestamp */ 1150 1155 printf( esc_html_x( '%1$s on %2$s %3$s', 'widgets', 'bbpress' ), $author_link, $reply_link, $show_date ); 1151 1156 … … 1157 1162 elseif ( ! empty( $author_link ) ) : 1158 1163 1159 / / translators: 1: reply author, 2: reply link1164 /* translators: 1: reply author, 2: reply link */ 1160 1165 printf( esc_html_x( '%1$s on %2$s', 'widgets', 'bbpress' ), $author_link, $reply_link ); 1161 1166 -
trunk/src/includes/core/theme-compat.php
r7348 r7360 802 802 'post_content' => $new_content, 803 803 'post_type' => '', 804 /* translators: %s: Topic tag name */ 804 805 'post_title' => sprintf( esc_html__( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ), 805 806 'post_status' => bbp_get_public_status_id(), -
trunk/src/includes/extend/akismet.php
r7359 r7360 629 629 $post_id, 630 630 sprintf( 631 esc_html__( 'Akismet overruled. Post status overridden to %s.', 'bbpress' ), 631 /* translators: %s: Post status */ 632 esc_html__( 'Post status was changed to %s', 'bbpress' ), 632 633 $_post->post_status 633 634 ), … … 652 653 $post_id, 653 654 sprintf( 654 esc_html__( 'Akismet overruled. Post status overridden to %s.', 'bbpress' ), 655 /* translators: %s: Post status */ 656 esc_html__( 'Post status was changed to %s', 'bbpress' ), 655 657 $_post->post_status 656 658 ), … … 666 668 $post_id, 667 669 sprintf( 670 /* translators: %s: Akismet response */ 668 671 esc_html__( 'Akismet was unable to check this post (response: %s), will automatically retry again later.', 'bbpress' ), 669 672 $this->last_post['bbp_akismet_result'] -
trunk/src/includes/extend/buddypress/activity.php
r7214 r7360 399 399 400 400 // Activity action & text 401 $activity_text = sprintf( esc_html__( '%1$s started the topic %2$s in the forum %3$s', 'bbpress' ), $user_link, $topic_link, $forum_link ); 401 $activity_text = sprintf( 402 /* translators: 1: User linked profile, 2: Topic linked title, 3: Forum linked title */ 403 esc_html__( '%1$s started the topic %2$s in the forum %3$s', 'bbpress' ), 404 $user_link, 405 $topic_link, 406 $forum_link 407 ); 402 408 $activity_action = apply_filters( 'bbp_activity_topic_create', $activity_text, $user_id, $topic_id, $forum_id ); 403 409 $activity_content = apply_filters( 'bbp_activity_topic_create_excerpt', $topic_content ); … … 537 543 538 544 // Activity action & text 539 $activity_text = sprintf( esc_html__( '%1$s replied to the topic %2$s in the forum %3$s', 'bbpress' ), $user_link, $topic_link, $forum_link ); 545 $activity_text = sprintf( 546 /* translators: 1: User linked profile, 2: Topic linked title, 3: Forum linked title */ 547 esc_html__( '%1$s replied to the topic %2$s in the forum %3$s', 'bbpress' ), 548 $user_link, 549 $topic_link, 550 $forum_link 551 ); 540 552 $activity_action = apply_filters( 'bbp_activity_reply_create', $activity_text, $user_id, $reply_id, $topic_id ); 541 553 $activity_content = apply_filters( 'bbp_activity_reply_create_excerpt', $reply_content ); -
trunk/src/includes/extend/buddypress/functions.php
r6850 r7360 775 775 function bbp_get_activity_actions() { 776 776 777 // Define activity actions with proper translation support 778 $actions = array( 779 780 'topic' => 781 /* translators: 1: User linked profile, 2: Topic linked title, 3: Forum linked title */ 782 esc_html__( '%1$s started the topic %2$s in the forum %3$s', 'bbpress' ), 783 784 'reply' => 785 /* translators: 1: User linked profile, 2: Topic linked title, 3: Forum linked title */ 786 esc_html__( '%1$s replied to the topic %2$s in the forum %3$s', 'bbpress' ) 787 ); 788 777 789 // Filter & return 778 return (array) apply_filters( 'bbp_get_activity_actions', array( 779 'topic' => esc_html__( '%1$s started the topic %2$s in the forum %3$s', 'bbpress' ), 780 'reply' => esc_html__( '%1$s replied to the topic %2$s in the forum %3$s', 'bbpress' ) 781 ) ); 790 return (array) apply_filters( 'bbp_get_activity_actions', $actions ); 782 791 } 783 792 -
trunk/src/includes/extend/buddypress/groups.php
r7357 r7360 484 484 <label for="bbp_group_forum_id"><?php esc_html_e( 'Group Forum:', 'bbpress' ); ?></label> 485 485 <?php 486 bbp_dropdown( array( 487 'select_id' => 'bbp_group_forum_id', 488 'show_none' => esc_html__( '— No forum —', 'bbpress' ), 489 'selected' => $forum_id 490 ) ); 486 bbp_dropdown( 487 array( 488 'select_id' => 'bbp_group_forum_id', 489 'show_none' => esc_html__( '— No forum —', 'bbpress' ), 490 'selected' => $forum_id 491 ) 492 ); 491 493 ?> 492 494 <p class="description"><?php esc_html_e( 'Network administrators can reconfigure which forum belongs to this group.', 'bbpress' ); ?></p> … … 1693 1695 } 1694 1696 1695 /**1696 * Fixes rewrite pagination in BuddyPress Group Forums & Topics.1697 * 1698 * Required for compatibility with BuddyPress > 12.0, where the /groups/1697 /** 1698 * Fixes rewrite pagination in BuddyPress Group Forums & Topics. 1699 * 1700 * Required for compatibility with BuddyPress > 12.0, where the /groups/ 1699 1701 * rewrite rule will be caught before bbPress's /page/ rule. 1700 1702 * … … 1704 1706 * @param string $type Type of variable to check with `is_a()` 1705 1707 * @return mixed $object Verified object if valid, Default or null if invalid 1706 */1707 public function rewrite_pagination( $object, $type = '' ) {1708 */ 1709 public function rewrite_pagination( $object, $type = '' ) { 1708 1710 1709 1711 // Bail if wrong global 1710 if ( 'wp_query' !== $type ) {1711 return $object;1712 }1712 if ( 'wp_query' !== $type ) { 1713 return $object; 1714 } 1713 1715 1714 1716 // Bail if not inside a BuddyPress Group 1715 if ( ! bp_is_group() ) {1716 return $object;1717 }1717 if ( ! bp_is_group() ) { 1718 return $object; 1719 } 1718 1720 1719 1721 // Bail if not inside a BuddyPress Group Forum 1720 if ( ! bp_is_current_action( 'forum' ) ) {1721 return $object;1722 }1722 if ( ! bp_is_current_action( 'forum' ) ) { 1723 return $object; 1724 } 1723 1725 1724 1726 // Default "paged" value 1725 $page_number = null;1726 1727 // Can't use bbp_is_single_topic() because it triggers a loop.1728 $is_single_topic = bp_is_action_variable( 'topic', 0 );1727 $page_number = null; 1728 1729 // Can't use bbp_is_single_topic() because it triggers a loop. 1730 $is_single_topic = bp_is_action_variable( 'topic', 0 ); 1729 1731 1730 1732 // Single Topic 1731 if ( true === $is_single_topic ) {1733 if ( true === $is_single_topic ) { 1732 1734 1733 1735 // Get the page number from 3rd position 1734 if ( bp_is_action_variable( 'page', 2 ) ) {1735 $page_number = bp_action_variable( 3 );1736 }1736 if ( bp_is_action_variable( 'page', 2 ) ) { 1737 $page_number = bp_action_variable( 3 ); 1738 } 1737 1739 1738 1740 // Single Forum 1739 } else {1741 } else { 1740 1742 1741 1743 // Get the page number from 1st position 1742 if ( bp_is_action_variable( 'page', 0 ) ) {1743 $page_number = bp_action_variable( 1 );1744 }1745 }1744 if ( bp_is_action_variable( 'page', 0 ) ) { 1745 $page_number = bp_action_variable( 1 ); 1746 } 1747 } 1746 1748 1747 1749 // Bail if no page number 1748 if ( empty( $page_number ) ) {1749 return $object;1750 }1750 if ( empty( $page_number ) ) { 1751 return $object; 1752 } 1751 1753 1752 1754 // Set the 'paged' WP_Query var to the new action-based value 1753 $object->set( 'paged', $page_number );1755 $object->set( 'paged', $page_number ); 1754 1756 1755 1757 // Return the filtered/modified object 1756 return $object;1757 }1758 return $object; 1759 } 1758 1760 1759 1761 /** -
trunk/src/includes/extend/buddypress/notifications.php
r7308 r7360 84 84 $action_item_count = (int) $action_item_count; 85 85 86 // Multiple 86 // Multiple replies 87 87 if ( $action_item_count > 1 ) { 88 88 $filter = 'bbp_multiple_new_subscription_notification'; 89 $text = sprintf( esc_html__( 'You have %1$d new replies to %2$s', 'bbpress' ), $action_item_count, $topic_title ); 90 91 // Single 89 $text = sprintf( 90 /* translators: 1: Number of replies, 2: Topic title */ 91 esc_html__( 'You have %1$d new replies to %2$s', 'bbpress' ), 92 $action_item_count, 93 $topic_title 94 ); 95 96 // Single reply 92 97 } else { 93 98 $filter = 'bbp_single_new_subscription_notification'; 94 $text = ! empty( $secondary_item_id ) 95 ? sprintf( esc_html__( 'You have %1$d new reply to %2$s from %3$s', 'bbpress' ), $action_item_count, $topic_title, bp_core_get_user_displayname( $secondary_item_id ) ) 96 : sprintf( esc_html__( 'You have %1$d new reply to %2$s', 'bbpress' ), $action_item_count, $topic_title ); 99 100 if ( ! empty( $secondary_item_id ) ) { 101 $text = sprintf( 102 /* translators: 1: Number of replies, 2: Topic title, 3: Reply author name */ 103 esc_html__( 'You have %1$d new reply to %2$s from %3$s', 'bbpress' ), 104 $action_item_count, 105 $topic_title, 106 bp_core_get_user_displayname( $secondary_item_id ) 107 ); 108 } else { 109 $text = sprintf( 110 /* translators: 1: Number of replies, 2: Topic title */ 111 esc_html__( 'You have %1$d new reply to %2$s', 'bbpress' ), 112 $action_item_count, 113 $topic_title 114 ); 115 } 97 116 } 98 117 -
trunk/src/includes/forums/functions.php
r7357 r7360 355 355 356 356 // WP_Error 357 357 358 } elseif ( is_wp_error( $forum_id ) ) { 358 bbp_add_error( 'bbp_forum_error', sprintf( __( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ), $forum_id->get_error_message() ) ); 359 360 // Generic error 359 bbp_add_error( 360 'bbp_forum_error', 361 sprintf( 362 /* translators: %s: Error message */ 363 esc_html__( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ), 364 $forum_id->get_error_message() 365 ) 366 ); 361 367 } else { 362 bbp_add_error( 'bbp_forum_error', __( '<strong>Error</strong>: The forum was not created.', 'bbpress' ) );363 }368 bbp_add_error( 'bbp_forum_error', __( '<strong>Error</strong>: The forum was not created.', 'bbpress' ) ); 369 } 364 370 } 365 371 … … 602 608 } else { 603 609 $append_error = ( is_wp_error( $forum_id ) && $forum_id->get_error_message() ) ? $forum_id->get_error_message() . ' ' : ''; 604 bbp_add_error( 'bbp_forum_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found with your forum: %s Please try again.', 'bbpress' ) ), $append_error ); 610 bbp_add_error( 611 'bbp_forum_error', 612 sprintf( 613 /* translators: %s: Error message */ 614 __( '<strong>Error</strong>: The following problem(s) have been found with your forum: %s Please try again.', 'bbpress' ) ), 615 $append_error 616 ); 605 617 } 606 618 } -
trunk/src/includes/forums/template.php
r7359 r7360 21 21 echo bbp_get_forum_post_type(); 22 22 } 23 /** 24 * Return the unique id of the custom post type for forums 25 * 26 * @since 2.0.0 bbPress (r2857) 27 * 28 * @return string The unique forum post type id 29 */ 30 function bbp_get_forum_post_type() { 23 24 /** 25 * Return the unique id of the custom post type for forums 26 * 27 * @since 2.0.0 bbPress (r2857) 28 * 29 * @return string The unique forum post type id 30 */ 31 function bbp_get_forum_post_type() { 31 32 32 33 // Filter & return 33 34 return apply_filters( 'bbp_get_forum_post_type', bbpress()->forum_post_type ); 34 } 35 35 } 36 36 37 37 /** … … 224 224 echo bbp_get_forum_id( $forum_id ); 225 225 } 226 /** 227 * Return the forum id 228 * 229 * @since 2.0.0 bbPress (r2464) 230 * 231 * @param $forum_id Optional. Used to check emptiness 232 * @return int The forum id 233 */ 234 function bbp_get_forum_id( $forum_id = 0 ) { 226 227 /** 228 * Return the forum id 229 * 230 * @since 2.0.0 bbPress (r2464) 231 * 232 * @param $forum_id Optional. Used to check emptiness 233 * @return int The forum id 234 */ 235 function bbp_get_forum_id( $forum_id = 0 ) { 235 236 $bbp = bbpress(); 236 237 $wp_query = bbp_get_wp_query(); … … 240 241 $bbp_forum_id = $forum_id; 241 242 242 // Currently inside a forum loop243 } elseif ( ! empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) {243 // Currently inside a forum loop 244 } elseif ( ! empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) { 244 245 $bbp_forum_id = $bbp->forum_query->post->ID; 245 246 246 // Currently inside a search loop247 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_forum( $bbp->search_query->post->ID ) ) {247 // Currently inside a search loop 248 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_forum( $bbp->search_query->post->ID ) ) { 248 249 $bbp_forum_id = $bbp->search_query->post->ID; 249 250 250 // Currently viewing a forum251 } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && ! empty( $bbp->current_forum_id ) ) {251 // Currently viewing a forum 252 } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && ! empty( $bbp->current_forum_id ) ) { 252 253 $bbp_forum_id = $bbp->current_forum_id; 253 254 254 // Currently viewing a forum255 } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && isset( $wp_query->post->ID ) ) {255 // Currently viewing a forum 256 } elseif ( ( bbp_is_single_forum() || bbp_is_forum_edit() ) && isset( $wp_query->post->ID ) ) { 256 257 $bbp_forum_id = $wp_query->post->ID; 257 258 258 // Currently viewing a topic259 } elseif ( bbp_is_single_topic() ) {259 // Currently viewing a topic 260 } elseif ( bbp_is_single_topic() ) { 260 261 $bbp_forum_id = bbp_get_topic_forum_id(); 261 262 262 // Fallback263 } else {263 // Fallback 264 } else { 264 265 $bbp_forum_id = 0; 265 }266 } 266 267 267 268 // Filter & return 268 269 return (int) apply_filters( 'bbp_get_forum_id', (int) $bbp_forum_id, $forum_id ); 269 }270 } 270 271 271 272 /** … … 326 327 echo esc_url( bbp_get_forum_permalink( $forum_id, $redirect_to ) ); 327 328 } 328 /** 329 * Return the link to the forum 330 * 331 * @since 2.0.0 bbPress (r2464) 332 * 333 * @param int $forum_id Optional. Forum id 334 * @param string $redirect_to Optional. Pass a redirect value for use with 335 * shortcodes and other fun things. 336 * 337 * @return string Permanent link to forum 338 */ 339 function bbp_get_forum_permalink( $forum_id = 0, $redirect_to = '' ) { 329 330 /** 331 * Return the link to the forum 332 * 333 * @since 2.0.0 bbPress (r2464) 334 * 335 * @param int $forum_id Optional. Forum id 336 * @param string $redirect_to Optional. Pass a redirect value for use with 337 * shortcodes and other fun things. 338 * 339 * @return string Permanent link to forum 340 */ 341 function bbp_get_forum_permalink( $forum_id = 0, $redirect_to = '' ) { 340 342 $forum_id = bbp_get_forum_id( $forum_id ); 341 343 … … 344 346 $forum_permalink = esc_url_raw( $redirect_to ); 345 347 346 // Use the topic permalink347 } else {348 // Use the topic permalink 349 } else { 348 350 $forum_permalink = get_permalink( $forum_id ); 349 }351 } 350 352 351 353 // Filter & return 352 354 return apply_filters( 'bbp_get_forum_permalink', $forum_permalink, $forum_id ); 353 }355 } 354 356 355 357 /** … … 363 365 echo bbp_get_forum_title( $forum_id ); 364 366 } 365 /** 366 * Return the title of the forum 367 * 368 * @since 2.0.0 bbPress (r2464) 369 * 370 * @param int $forum_id Optional. Forum id 371 * @return string Title of forum 372 */ 373 function bbp_get_forum_title( $forum_id = 0 ) { 367 368 /** 369 * Return the title of the forum 370 * 371 * @since 2.0.0 bbPress (r2464) 372 * 373 * @param int $forum_id Optional. Forum id 374 * @return string Title of forum 375 */ 376 function bbp_get_forum_title( $forum_id = 0 ) { 374 377 $forum_id = bbp_get_forum_id( $forum_id ); 375 378 $title = get_post_field( 'post_title', $forum_id ); … … 378 381 // Filter & return 379 382 return apply_filters( 'bbp_get_forum_title', $title, $forum_id ); 380 }383 } 381 384 382 385 /** … … 390 393 echo bbp_get_forum_archive_title( $title ); 391 394 } 392 /** 393 * Return the forum archive title 394 * 395 * @since 2.0.0 bbPress (r3249) 396 * 397 * @param string $title Default text to use as title 398 * 399 * @return string The forum archive title 400 */ 401 function bbp_get_forum_archive_title( $title = '' ) { 395 396 /** 397 * Return the forum archive title 398 * 399 * @since 2.0.0 bbPress (r3249) 400 * 401 * @param string $title Default text to use as title 402 * 403 * @return string The forum archive title 404 */ 405 function bbp_get_forum_archive_title( $title = '' ) { 402 406 403 407 // If no title was passed … … 409 413 $title = get_the_title( $page->ID ); 410 414 411 // Default to forum post type name label412 } else {415 // Default to forum post type name label 416 } else { 413 417 $fto = get_post_type_object( bbp_get_forum_post_type() ); 414 418 $title = $fto->labels->name; 415 }416 419 } 420 } 417 421 418 422 // Filter & return 419 423 return apply_filters( 'bbp_get_forum_archive_title', $title ); 420 }424 } 421 425 422 426 /** … … 430 434 echo bbp_get_forum_content( $forum_id ); 431 435 } 432 /** 433 * Return the content of the forum 434 * 435 * @since 2.0.0 bbPress (r2780) 436 * 437 * @param int $forum_id Optional. Topic id 438 * 439 * @return string Content of the forum 440 */ 441 function bbp_get_forum_content( $forum_id = 0 ) { 436 437 /** 438 * Return the content of the forum 439 * 440 * @since 2.0.0 bbPress (r2780) 441 * 442 * @param int $forum_id Optional. Topic id 443 * 444 * @return string Content of the forum 445 */ 446 function bbp_get_forum_content( $forum_id = 0 ) { 442 447 $forum_id = bbp_get_forum_id( $forum_id ); 443 448 … … 445 450 if ( post_password_required( $forum_id ) ) { 446 451 return get_the_password_form(); 447 }452 } 448 453 449 454 $content = get_post_field( 'post_content', $forum_id ); … … 451 456 // Filter & return 452 457 return apply_filters( 'bbp_get_forum_content', $content, $forum_id ); 453 }458 } 454 459 455 460 /** … … 474 479 echo bbp_get_forum_last_active_id( $forum_id ); 475 480 } 476 /** 477 * Return the forums last active ID 478 * 479 * @since 2.0.0 bbPress (r2860) 480 * 481 * @param int $forum_id Optional. Forum id 482 * the last active id and forum id 483 * @return int Forum's last active id 484 */ 485 function bbp_get_forum_last_active_id( $forum_id = 0 ) { 481 482 /** 483 * Return the forums last active ID 484 * 485 * @since 2.0.0 bbPress (r2860) 486 * 487 * @param int $forum_id Optional. Forum id 488 * the last active id and forum id 489 * @return int Forum's last active id 490 */ 491 function bbp_get_forum_last_active_id( $forum_id = 0 ) { 486 492 $forum_id = bbp_get_forum_id( $forum_id ); 487 493 $active_id = (int) get_post_meta( $forum_id, '_bbp_last_active_id', true ); … … 489 495 // Filter & return 490 496 return (int) apply_filters( 'bbp_get_forum_last_active_id', $active_id, $forum_id ); 491 }497 } 492 498 493 499 /** … … 501 507 echo bbp_get_forum_last_active_time( $forum_id ); 502 508 } 503 /** 504 * Return the forums last update date/time (aka freshness) 505 * 506 * @since 2.0.0 bbPress (r2464) 507 * 508 * @param int $forum_id Optional. Forum id 509 * @return string Forum last update date/time (freshness) 510 */ 511 function bbp_get_forum_last_active_time( $forum_id = 0 ) { 509 510 /** 511 * Return the forums last update date/time (aka freshness) 512 * 513 * @since 2.0.0 bbPress (r2464) 514 * 515 * @param int $forum_id Optional. Forum id 516 * @return string Forum last update date/time (freshness) 517 */ 518 function bbp_get_forum_last_active_time( $forum_id = 0 ) { 512 519 513 520 // Verify forum and get last active meta … … 517 524 if ( empty( $last_active ) ) { 518 525 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); 526 519 527 if ( ! empty( $reply_id ) ) { 520 528 $last_active = get_post_field( 'post_date', $reply_id ); 521 } else {529 } else { 522 530 $topic_id = bbp_get_forum_last_topic_id( $forum_id ); 523 531 if ( ! empty( $topic_id ) ) { 524 532 $last_active = bbp_get_topic_last_active_time( $topic_id ); 525 }526 533 } 527 534 } 528 529 $active_time = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : ''; 535 } 536 537 $active_time = ! empty( $last_active ) 538 ? bbp_get_time_since( bbp_convert_date( $last_active ) ) 539 : ''; 530 540 531 541 // Filter & return 532 542 return apply_filters( 'bbp_get_forum_last_active', $active_time, $forum_id ); 533 }543 } 534 544 535 545 /** … … 545 555 echo bbp_get_forum_freshness_link( $forum_id ); 546 556 } 547 /** 548 * Returns link to the most recent activity inside a forum. 549 * 550 * Returns a complete link with attributes and content. 551 * 552 * @since 2.0.0 bbPress (r2625) 553 * 554 * @param int $forum_id Optional. Forum id 555 */ 556 function bbp_get_forum_freshness_link( $forum_id = 0 ) { 557 558 /** 559 * Returns link to the most recent activity inside a forum. 560 * 561 * Returns a complete link with attributes and content. 562 * 563 * @since 2.0.0 bbPress (r2625) 564 * 565 * @param int $forum_id Optional. Forum id 566 */ 567 function bbp_get_forum_freshness_link( $forum_id = 0 ) { 557 568 $forum_id = bbp_get_forum_id( $forum_id ); 558 569 $active_id = bbp_get_forum_last_active_id( $forum_id ); … … 561 572 if ( empty( $active_id ) ) { 562 573 $active_id = bbp_get_forum_last_reply_id( $forum_id ); 563 }574 } 564 575 565 576 if ( empty( $active_id ) ) { 566 577 $active_id = bbp_get_forum_last_topic_id( $forum_id ); 567 }578 } 568 579 569 580 if ( bbp_is_topic( $active_id ) ) { 570 581 $link_url = bbp_get_forum_last_topic_permalink( $forum_id ); 571 582 $title = bbp_get_forum_last_topic_title( $forum_id ); 572 } elseif ( bbp_is_reply( $active_id ) ) {583 } elseif ( bbp_is_reply( $active_id ) ) { 573 584 $link_url = bbp_get_forum_last_reply_url( $forum_id ); 574 585 $title = bbp_get_forum_last_reply_title( $forum_id ); 575 }586 } 576 587 577 588 $time_since = bbp_get_forum_last_active_time( $forum_id ); … … 579 590 if ( ! empty( $time_since ) && ! empty( $link_url ) ) { 580 591 $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>'; 581 } else {592 } else { 582 593 $anchor = esc_html__( 'No Topics', 'bbpress' ); 583 }594 } 584 595 585 596 // Filter & return 586 597 return apply_filters( 'bbp_get_forum_freshness_link', $anchor, $forum_id, $time_since, $link_url, $title, $active_id ); 587 }598 } 588 599 589 600 /** … … 597 608 echo bbp_get_forum_parent_id( $forum_id ); 598 609 } 599 /** 600 * Return ID of forum parent, if exists 601 * 602 * @since 2.1.0 bbPress (r3675) 603 * 604 * @param int $forum_id Optional. Forum id 605 * @return int Forum parent 606 */ 607 function bbp_get_forum_parent_id( $forum_id = 0 ) { 610 611 /** 612 * Return ID of forum parent, if exists 613 * 614 * @since 2.1.0 bbPress (r3675) 615 * 616 * @param int $forum_id Optional. Forum id 617 * @return int Forum parent 618 */ 619 function bbp_get_forum_parent_id( $forum_id = 0 ) { 608 620 $forum_id = bbp_get_forum_id( $forum_id ); 609 621 $parent_id = (int) get_post_field( 'post_parent', $forum_id ); … … 612 624 if ( empty( $parent_id ) ) { 613 625 $parent_id = (int) get_post_meta( $forum_id, '_bbp_forum_id', true ); 614 }626 } 615 627 616 628 // Filter 617 629 if ( ! empty( $parent_id ) ) { 618 630 $parent_id = (int) bbp_get_forum_id( $parent_id ); 619 }631 } 620 632 621 633 // Filter & return 622 634 return (int) apply_filters( 'bbp_get_forum_parent_id', $parent_id, $forum_id ); 623 }635 } 624 636 625 637 /** … … 809 821 } 810 822 811 /**812 * Get the forum subscription link813 *814 * A custom wrapper for bbp_get_user_subscribe_link()815 *816 * @since 2.5.0 bbPress (r5156)817 * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support818 */819 function bbp_get_forum_subscription_link( $args = array() ) {823 /** 824 * Get the forum subscription link 825 * 826 * A custom wrapper for bbp_get_user_subscribe_link() 827 * 828 * @since 2.5.0 bbPress (r5156) 829 * @since 2.6.0 bbPress (r6308) Add 'redirect_to' support 830 */ 831 function bbp_get_forum_subscription_link( $args = array() ) { 820 832 821 833 // Defaults 822 834 $retval = false; 823 835 $redirect_to = bbp_is_subscriptions() 824 ? bbp_get_subscriptions_permalink()825 : '';836 ? bbp_get_subscriptions_permalink() 837 : ''; 826 838 827 839 // Parse the arguments 828 840 $r = bbp_parse_args( $args, array( 829 'user_id' => bbp_get_current_user_id(),830 'object_id' => bbp_get_forum_id(),831 'object_type' => 'post',832 'before' => '',833 'after' => '',834 'subscribe' => esc_html__( 'Subscribe', 'bbpress' ),835 'unsubscribe' => esc_html__( 'Unsubscribe', 'bbpress' ),836 'redirect_to' => $redirect_to841 'user_id' => bbp_get_current_user_id(), 842 'object_id' => bbp_get_forum_id(), 843 'object_type' => 'post', 844 'before' => '', 845 'after' => '', 846 'subscribe' => esc_html__( 'Subscribe', 'bbpress' ), 847 'unsubscribe' => esc_html__( 'Unsubscribe', 'bbpress' ), 848 'redirect_to' => $redirect_to 837 849 ), 'get_forum_subscribe_link' ); 838 850 839 // No link for categories until we support subscription hierarchy840 // @see https://bbpress.trac.wordpress.org/ticket/2475841 if ( ! bbp_is_forum_category() ) {842 $retval = bbp_get_user_subscribe_link( $r );843 } 844 845 // Filter & return846 return apply_filters( 'bbp_get_forum_subscribe_link', $retval, $r, $args );847 }851 // No link for categories until we support subscription hierarchy 852 // @see https://bbpress.trac.wordpress.org/ticket/2475 853 if ( ! bbp_is_forum_category() ) { 854 $retval = bbp_get_user_subscribe_link( $r ); 855 } 856 857 // Filter & return 858 return apply_filters( 'bbp_get_forum_subscribe_link', $retval, $r, $args ); 859 } 848 860 849 861 /** Forum Last Topic **********************************************************/ … … 859 871 echo bbp_get_forum_last_topic_id( $forum_id ); 860 872 } 861 /** 862 * Return the forum's last topic id 863 * 864 * @since 2.0.0 bbPress (r2464) 865 * 866 * @param int $forum_id Optional. Forum id 867 * @return int Forum's last topic id 868 */ 869 function bbp_get_forum_last_topic_id( $forum_id = 0 ) { 873 874 /** 875 * Return the forum's last topic id 876 * 877 * @since 2.0.0 bbPress (r2464) 878 * 879 * @param int $forum_id Optional. Forum id 880 * @return int Forum's last topic id 881 */ 882 function bbp_get_forum_last_topic_id( $forum_id = 0 ) { 870 883 $forum_id = bbp_get_forum_id( $forum_id ); 871 884 $topic_id = (int) get_post_meta( $forum_id, '_bbp_last_topic_id', true ); … … 873 886 // Filter & return 874 887 return (int) apply_filters( 'bbp_get_forum_last_topic_id', $topic_id, $forum_id ); 875 }888 } 876 889 877 890 /** … … 885 898 echo bbp_get_forum_last_topic_title( $forum_id ); 886 899 } 887 /** 888 * Return the title of the last topic inside a forum 889 * 890 * @since 2.0.0 bbPress (r2625) 891 * 892 * @param int $forum_id Optional. Forum id 893 * @return string Forum's last topic's title 894 */ 895 function bbp_get_forum_last_topic_title( $forum_id = 0 ) { 900 901 /** 902 * Return the title of the last topic inside a forum 903 * 904 * @since 2.0.0 bbPress (r2625) 905 * 906 * @param int $forum_id Optional. Forum id 907 * @return string Forum's last topic's title 908 */ 909 function bbp_get_forum_last_topic_title( $forum_id = 0 ) { 896 910 $forum_id = bbp_get_forum_id( $forum_id ); 897 911 $topic_id = bbp_get_forum_last_topic_id( $forum_id ); 898 $title = ! empty( $topic_id ) ? bbp_get_topic_title( $topic_id ) : ''; 912 $title = ! empty( $topic_id ) 913 ? bbp_get_topic_title( $topic_id ) 914 : ''; 899 915 900 916 // Filter & return 901 917 return apply_filters( 'bbp_get_forum_last_topic_title', $title, $forum_id ); 902 }918 } 903 919 904 920 /** … … 912 928 echo esc_url( bbp_get_forum_last_topic_permalink( $forum_id ) ); 913 929 } 914 /** 915 * Return the link to the last topic in a forum 916 * 917 * @since 2.0.0 bbPress (r2464) 918 * 919 * @param int $forum_id Optional. Forum id 920 * @return string Permanent link to topic 921 */ 922 function bbp_get_forum_last_topic_permalink( $forum_id = 0 ) { 930 931 /** 932 * Return the link to the last topic in a forum 933 * 934 * @since 2.0.0 bbPress (r2464) 935 * 936 * @param int $forum_id Optional. Forum id 937 * @return string Permanent link to topic 938 */ 939 function bbp_get_forum_last_topic_permalink( $forum_id = 0 ) { 923 940 $forum_id = bbp_get_forum_id( $forum_id ); 924 941 $topic_id = bbp_get_forum_last_topic_id( $forum_id ); … … 927 944 // Filter & return 928 945 return apply_filters( 'bbp_get_forum_last_topic_permalink', $link, $forum_id, $topic_id ); 929 }946 } 930 947 931 948 /** … … 956 973 echo bbp_get_forum_last_topic_author_link( $forum_id ); 957 974 } 958 /** 959 * Return link to author of last topic of forum 960 * 961 * @since 2.0.0 bbPress (r2625) 962 * 963 * @param int $forum_id Optional. Forum id 964 * @return string Forum's last topic's author link 965 */ 966 function bbp_get_forum_last_topic_author_link( $forum_id = 0 ) { 975 976 /** 977 * Return link to author of last topic of forum 978 * 979 * @since 2.0.0 bbPress (r2625) 980 * 981 * @param int $forum_id Optional. Forum id 982 * @return string Forum's last topic's author link 983 */ 984 function bbp_get_forum_last_topic_author_link( $forum_id = 0 ) { 967 985 $forum_id = bbp_get_forum_id( $forum_id ); 968 986 $author_id = bbp_get_forum_last_topic_author_id( $forum_id ); … … 971 989 // Filter & return 972 990 return apply_filters( 'bbp_get_forum_last_topic_author_link', $author_link, $forum_id ); 973 }991 } 974 992 975 993 /** Forum Last Reply **********************************************************/ … … 985 1003 echo bbp_get_forum_last_reply_id( $forum_id ); 986 1004 } 987 /** 988 * Return the forums last reply id 989 * 990 * @since 2.0.0 bbPress (r2464) 991 * 992 * @param int $forum_id Optional. Forum id 993 * @return int Forum's last reply id 994 */ 995 function bbp_get_forum_last_reply_id( $forum_id = 0 ) { 1005 1006 /** 1007 * Return the forums last reply id 1008 * 1009 * @since 2.0.0 bbPress (r2464) 1010 * 1011 * @param int $forum_id Optional. Forum id 1012 * @return int Forum's last reply id 1013 */ 1014 function bbp_get_forum_last_reply_id( $forum_id = 0 ) { 996 1015 $forum_id = bbp_get_forum_id( $forum_id ); 997 1016 $reply_id = (int) get_post_meta( $forum_id, '_bbp_last_reply_id', true ); … … 999 1018 // Filter & return 1000 1019 return (int) apply_filters( 'bbp_get_forum_last_reply_id', $reply_id, $forum_id ); 1001 }1020 } 1002 1021 1003 1022 /** … … 1009 1028 echo bbp_get_forum_last_reply_title( $forum_id ); 1010 1029 } 1011 /** 1012 * Return the title of the last reply inside a forum 1013 * 1014 * @param int $forum_id Optional. Forum id 1015 * @return string 1016 */ 1017 function bbp_get_forum_last_reply_title( $forum_id = 0 ) { 1030 1031 /** 1032 * Return the title of the last reply inside a forum 1033 * 1034 * @param int $forum_id Optional. Forum id 1035 * @return string 1036 */ 1037 function bbp_get_forum_last_reply_title( $forum_id = 0 ) { 1018 1038 $forum_id = bbp_get_forum_id( $forum_id ); 1019 1039 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); … … 1022 1042 // Filter & return 1023 1043 return apply_filters( 'bbp_get_forum_last_reply_title', $title, $forum_id, $reply_id ); 1024 }1044 } 1025 1045 1026 1046 /** … … 1034 1054 echo esc_url( bbp_get_forum_last_reply_permalink( $forum_id ) ); 1035 1055 } 1036 /** 1037 * Return the link to the last reply in a forum 1038 * 1039 * @since 2.0.0 bbPress (r2464) 1040 * 1041 * @param int $forum_id Optional. Forum id 1042 * 1043 * @return string Permanent link to the forum's last reply 1044 */ 1045 function bbp_get_forum_last_reply_permalink( $forum_id = 0 ) { 1056 1057 /** 1058 * Return the link to the last reply in a forum 1059 * 1060 * @since 2.0.0 bbPress (r2464) 1061 * 1062 * @param int $forum_id Optional. Forum id 1063 * 1064 * @return string Permanent link to the forum's last reply 1065 */ 1066 function bbp_get_forum_last_reply_permalink( $forum_id = 0 ) { 1046 1067 $forum_id = bbp_get_forum_id( $forum_id ); 1047 1068 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); … … 1050 1071 // Filter & return 1051 1072 return apply_filters( 'bbp_get_forum_last_reply_permalink', $link, $forum_id, $reply_id ); 1052 }1073 } 1053 1074 1054 1075 /** … … 1062 1083 echo esc_url( bbp_get_forum_last_reply_url( $forum_id ) ); 1063 1084 } 1064 /** 1065 * Return the url to the last reply in a forum 1066 * 1067 * @since 2.0.0 bbPress (r2683) 1068 * 1069 * @param int $forum_id Optional. Forum id 1070 * @return string Paginated URL to latest reply 1071 */ 1072 function bbp_get_forum_last_reply_url( $forum_id = 0 ) { 1085 1086 /** 1087 * Return the url to the last reply in a forum 1088 * 1089 * @since 2.0.0 bbPress (r2683) 1090 * 1091 * @param int $forum_id Optional. Forum id 1092 * @return string Paginated URL to latest reply 1093 */ 1094 function bbp_get_forum_last_reply_url( $forum_id = 0 ) { 1073 1095 $forum_id = bbp_get_forum_id( $forum_id ); 1074 1096 … … 1078 1100 $reply_url = bbp_get_reply_url( $reply_id ); 1079 1101 1080 // No replies, so look for topics and use last permalink1081 } else {1102 // No replies, so look for topics and use last permalink 1103 } else { 1082 1104 $reply_url = bbp_get_forum_last_topic_permalink( $forum_id ); 1083 1105 … … 1085 1107 if ( empty( $reply_url ) ) { 1086 1108 $reply_url = ''; 1087 }1088 1109 } 1110 } 1089 1111 1090 1112 // Filter & return 1091 1113 return apply_filters( 'bbp_get_forum_last_reply_url', $reply_url, $forum_id, $reply_id ); 1092 }1114 } 1093 1115 1094 1116 /** … … 1102 1124 echo bbp_get_forum_last_reply_author_id( $forum_id ); 1103 1125 } 1104 /** 1105 * Return author ID of last reply of forum 1106 * 1107 * @since 2.0.0 bbPress (r2625) 1108 * 1109 * @param int $forum_id Optional. Forum id 1110 * @return int Forum's last reply author id 1111 */ 1112 function bbp_get_forum_last_reply_author_id( $forum_id = 0 ) { 1126 1127 /** 1128 * Return author ID of last reply of forum 1129 * 1130 * @since 2.0.0 bbPress (r2625) 1131 * 1132 * @param int $forum_id Optional. Forum id 1133 * @return int Forum's last reply author id 1134 */ 1135 function bbp_get_forum_last_reply_author_id( $forum_id = 0 ) { 1113 1136 $forum_id = bbp_get_forum_id( $forum_id ); 1114 1137 $reply_id = bbp_get_forum_last_reply_id( $forum_id ); … … 1117 1140 // Filter & return 1118 1141 return apply_filters( 'bbp_get_forum_last_reply_author_id', $author_id, $forum_id, $reply_id ); 1119 }1142 } 1120 1143 1121 1144 /** … … 1129 1152 echo bbp_get_forum_last_reply_author_link( $forum_id ); 1130 1153 } 1131 /** 1132 * Return link to author of last reply of forum 1133 * 1134 * @since 2.0.0 bbPress (r2625) 1135 * 1136 * @param int $forum_id Optional. Forum id 1137 * @return string Link to author of last reply of forum 1138 */ 1139 function bbp_get_forum_last_reply_author_link( $forum_id = 0 ) { 1154 1155 /** 1156 * Return link to author of last reply of forum 1157 * 1158 * @since 2.0.0 bbPress (r2625) 1159 * 1160 * @param int $forum_id Optional. Forum id 1161 * @return string Link to author of last reply of forum 1162 */ 1163 function bbp_get_forum_last_reply_author_link( $forum_id = 0 ) { 1140 1164 $forum_id = bbp_get_forum_id( $forum_id ); 1141 1165 $author_id = bbp_get_forum_last_reply_author_id( $forum_id ); … … 1144 1168 // Filter & return 1145 1169 return apply_filters( 'bbp_get_forum_last_reply_author_link', $author_link, $forum_id, $author_id ); 1146 }1170 } 1147 1171 1148 1172 /** Forum Counts **************************************************************/ … … 1159 1183 } 1160 1184 1161 /**1162 * Return the topics link of the forum1163 *1164 * @since 2.0.0 bbPress (r2883)1165 *1166 * @param int $forum_id Optional. Topic id1167 */1168 function bbp_get_forum_topics_link( $forum_id = 0 ) {1185 /** 1186 * Return the topics link of the forum 1187 * 1188 * @since 2.0.0 bbPress (r2883) 1189 * 1190 * @param int $forum_id Optional. Topic id 1191 */ 1192 function bbp_get_forum_topics_link( $forum_id = 0 ) { 1169 1193 $forum_id = bbp_get_forum_id( $forum_id ); 1170 1194 $link = bbp_get_forum_permalink( $forum_id ); 1195 /* translators: %s: Number of topics */ 1171 1196 $topics = sprintf( _n( '%s topic', '%s topics', bbp_get_forum_topic_count( $forum_id, true, true ), 'bbpress' ), bbp_get_forum_topic_count( $forum_id, true, false ) ); 1172 1197 1173 1198 // First link never has view=all 1174 1199 $retval = bbp_get_view_all( 'edit_others_topics' ) 1175 ? "<a href='" . esc_url( bbp_remove_view_all( $link ) ) . "'>" . esc_html( $topics ) . '</a>'1176 : esc_html( $topics );1200 ? "<a href='" . esc_url( bbp_remove_view_all( $link ) ) . "'>" . esc_html( $topics ) . '</a>' 1201 : esc_html( $topics ); 1177 1202 1178 1203 // Get deleted topics … … 1184 1209 // Hidden text 1185 1210 $deleted_num = bbp_get_forum_topic_count_hidden( $forum_id, false, false ); 1211 /* translators: %s: Number of hidden topics */ 1186 1212 $extra = ' ' . sprintf( _n( '(+%s hidden)', '(+%s hidden)', $deleted_int, 'bbpress' ), $deleted_num ); 1187 1213 … … 1190 1216 ? " <a href='" . esc_url( bbp_add_view_all( $link, true ) ) . "'>" . esc_html( $extra ) . '</a>' 1191 1217 : " {$extra}"; 1192 }1218 } 1193 1219 1194 1220 // Filter & return 1195 1221 return apply_filters( 'bbp_get_forum_topics_link', $retval, $forum_id ); 1196 }1222 } 1197 1223 1198 1224 /** … … 1207 1233 echo bbp_get_forum_subforum_count( $forum_id, $integer ); 1208 1234 } 1209 /** 1210 * Return total subforum count of a forum 1211 * 1212 * @since 2.0.0 bbPress (r2464) 1213 * 1214 * @param int $forum_id Optional. Forum id 1215 * @param boolean $integer Optional. Whether or not to format the result 1216 * @return int Forum's subforum count 1217 */ 1218 function bbp_get_forum_subforum_count( $forum_id = 0, $integer = false ) { 1235 1236 /** 1237 * Return total subforum count of a forum 1238 * 1239 * @since 2.0.0 bbPress (r2464) 1240 * 1241 * @param int $forum_id Optional. Forum id 1242 * @param boolean $integer Optional. Whether or not to format the result 1243 * @return int Forum's subforum count 1244 */ 1245 function bbp_get_forum_subforum_count( $forum_id = 0, $integer = false ) { 1219 1246 $forum_id = bbp_get_forum_id( $forum_id ); 1220 1247 $forum_count = (int) get_post_meta( $forum_id, '_bbp_forum_subforum_count', true ); 1221 1248 $filter = ( true === $integer ) 1222 ? 'bbp_get_forum_subforum_count_int'1223 : 'bbp_get_forum_subforum_count';1249 ? 'bbp_get_forum_subforum_count_int' 1250 : 'bbp_get_forum_subforum_count'; 1224 1251 1225 1252 return apply_filters( $filter, $forum_count, $forum_id ); 1226 }1253 } 1227 1254 1228 1255 /** … … 1238 1265 echo bbp_get_forum_topic_count( $forum_id, $total_count, $integer ); 1239 1266 } 1240 /** 1241 * Return total topic count of a forum 1242 * 1243 * @since 2.0.0 bbPress (r2464) 1244 * 1245 * @param int $forum_id Optional. Forum id 1246 * @param bool $total_count Optional. To get the total count or normal 1247 * count? Defaults to total. 1248 * @param boolean $integer Optional. Whether or not to format the result 1249 * @return int Forum topic count 1250 */ 1251 function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true, $integer = false ) { 1267 1268 /** 1269 * Return total topic count of a forum 1270 * 1271 * @since 2.0.0 bbPress (r2464) 1272 * 1273 * @param int $forum_id Optional. Forum id 1274 * @param bool $total_count Optional. To get the total count or normal 1275 * count? Defaults to total. 1276 * @param boolean $integer Optional. Whether or not to format the result 1277 * @return int Forum topic count 1278 */ 1279 function bbp_get_forum_topic_count( $forum_id = 0, $total_count = true, $integer = false ) { 1252 1280 $forum_id = bbp_get_forum_id( $forum_id ); 1253 1281 $meta_key = empty( $total_count ) ? '_bbp_topic_count' : '_bbp_total_topic_count'; 1254 1282 $topics = (int) get_post_meta( $forum_id, $meta_key, true ); 1255 1283 $filter = ( true === $integer ) 1256 ? 'bbp_get_forum_topic_count_int'1257 : 'bbp_get_forum_topic_count';1284 ? 'bbp_get_forum_topic_count_int' 1285 : 'bbp_get_forum_topic_count'; 1258 1286 1259 1287 return apply_filters( $filter, $topics, $forum_id ); 1260 }1288 } 1261 1289 1262 1290 /** … … 1272 1300 echo bbp_get_forum_reply_count( $forum_id, $total_count, $integer ); 1273 1301 } 1274 /** 1275 * Return total post count of a forum 1276 * 1277 * @since 2.0.0 bbPress (r2464) 1278 * 1279 * @param int $forum_id Optional. Forum id 1280 * @param bool $total_count Optional. To get the total count or normal 1281 * count? 1282 * @param boolean $integer Optional. Whether or not to format the result 1283 * @return int Forum reply count 1284 */ 1285 function bbp_get_forum_reply_count( $forum_id = 0, $total_count = true, $integer = false ) { 1302 1303 /** 1304 * Return total post count of a forum 1305 * 1306 * @since 2.0.0 bbPress (r2464) 1307 * 1308 * @param int $forum_id Optional. Forum id 1309 * @param bool $total_count Optional. To get the total count or normal 1310 * count? 1311 * @param boolean $integer Optional. Whether or not to format the result 1312 * @return int Forum reply count 1313 */ 1314 function bbp_get_forum_reply_count( $forum_id = 0, $total_count = true, $integer = false ) { 1286 1315 $forum_id = bbp_get_forum_id( $forum_id ); 1287 1316 $meta_key = empty( $total_count ) ? '_bbp_reply_count' : '_bbp_total_reply_count'; 1288 1317 $replies = (int) get_post_meta( $forum_id, $meta_key, true ); 1289 1318 $filter = ( true === $integer ) 1290 ? 'bbp_get_forum_reply_count_int'1291 : 'bbp_get_forum_reply_count';1319 ? 'bbp_get_forum_reply_count_int' 1320 : 'bbp_get_forum_reply_count'; 1292 1321 1293 1322 return apply_filters( $filter, $replies, $forum_id ); 1294 }1323 } 1295 1324 1296 1325 /** … … 1306 1335 echo bbp_get_forum_post_count( $forum_id, $total_count, $integer ); 1307 1336 } 1308 /** 1309 * Return total post count of a forum 1310 * 1311 * @since 2.0.0 bbPress (r2954) 1312 * 1313 * @param int $forum_id Optional. Forum id 1314 * @param bool $total_count Optional. To get the total count or normal 1315 * count? 1316 * @param boolean $integer Optional. Whether or not to format the result 1317 * @return int Forum post count 1318 */ 1319 function bbp_get_forum_post_count( $forum_id = 0, $total_count = true, $integer = false ) { 1337 1338 /** 1339 * Return total post count of a forum 1340 * 1341 * @since 2.0.0 bbPress (r2954) 1342 * 1343 * @param int $forum_id Optional. Forum id 1344 * @param bool $total_count Optional. To get the total count or normal 1345 * count? 1346 * @param boolean $integer Optional. Whether or not to format the result 1347 * @return int Forum post count 1348 */ 1349 function bbp_get_forum_post_count( $forum_id = 0, $total_count = true, $integer = false ) { 1320 1350 $forum_id = bbp_get_forum_id( $forum_id ); 1321 1351 $topics = bbp_get_forum_topic_count( $forum_id, $total_count, true ); … … 1323 1353 $retval = ( $replies + $topics ); 1324 1354 $filter = ( true === $integer ) 1325 ? 'bbp_get_forum_post_count_int'1326 : 'bbp_get_forum_post_count';1355 ? 'bbp_get_forum_post_count_int' 1356 : 'bbp_get_forum_post_count'; 1327 1357 1328 1358 return apply_filters( $filter, $retval, $forum_id ); 1329 }1359 } 1330 1360 1331 1361 /** … … 1343 1373 echo bbp_get_forum_topic_count_hidden( $forum_id, $total_count, $integer ); 1344 1374 } 1345 /** 1346 * Return total hidden topic count of a forum (hidden includes trashed, 1347 * spammed and pending topics) 1348 * 1349 * @since 2.0.0 bbPress (r2883) 1350 * @since 2.6.0 bbPress (r6922) Changed function signature to add total counts 1351 * 1352 * @param int $forum_id Optional. Forum id 1353 * @param bool $total_count Optional. To get the total count or normal count? 1354 * @param boolean $integer Optional. Whether or not to format the result 1355 * @return int Topic hidden topic count 1356 */ 1357 function bbp_get_forum_topic_count_hidden( $forum_id = 0, $total_count = true, $integer = null ) { 1375 1376 /** 1377 * Return total hidden topic count of a forum (hidden includes trashed, 1378 * spammed and pending topics) 1379 * 1380 * @since 2.0.0 bbPress (r2883) 1381 * @since 2.6.0 bbPress (r6922) Changed function signature to add total counts 1382 * 1383 * @param int $forum_id Optional. Forum id 1384 * @param bool $total_count Optional. To get the total count or normal count? 1385 * @param boolean $integer Optional. Whether or not to format the result 1386 * @return int Topic hidden topic count 1387 */ 1388 function bbp_get_forum_topic_count_hidden( $forum_id = 0, $total_count = true, $integer = null ) { 1358 1389 $forum_id = bbp_get_forum_id( $forum_id ); 1359 1390 $meta_key = empty( $total_count ) ? '_bbp_topic_count_hidden' : '_bbp_total_topic_count_hidden'; 1360 1391 $topics = (int) get_post_meta( $forum_id, $meta_key, true ); 1361 1392 $filter = ( true === $integer ) 1362 ? 'bbp_get_forum_topic_count_hidden_int'1363 : 'bbp_get_forum_topic_count_hidden';1393 ? 'bbp_get_forum_topic_count_hidden_int' 1394 : 'bbp_get_forum_topic_count_hidden'; 1364 1395 1365 1396 return apply_filters( $filter, $topics, $forum_id ); 1366 }1397 } 1367 1398 1368 1399 /** … … 1379 1410 echo bbp_get_forum_reply_count_hidden( $forum_id, $total_count, $integer ); 1380 1411 } 1381 /** 1382 * Return total hidden reply count of a forum (hidden includes trashed, 1383 * spammed and pending replies) 1384 * 1385 * @since 2.6.0 bbPress (r6922) 1386 * 1387 * @param int $forum_id Optional. Forum id 1388 * @param bool $total_count Optional. To get the total count or normal 1389 * count? 1390 * @param boolean $integer Optional. Whether or not to format the result 1391 * @return int Forum reply count 1392 */ 1393 function bbp_get_forum_reply_count_hidden( $forum_id = 0, $total_count = true, $integer = false ) { 1412 1413 /** 1414 * Return total hidden reply count of a forum (hidden includes trashed, 1415 * spammed and pending replies) 1416 * 1417 * @since 2.6.0 bbPress (r6922) 1418 * 1419 * @param int $forum_id Optional. Forum id 1420 * @param bool $total_count Optional. To get the total count or normal 1421 * count? 1422 * @param boolean $integer Optional. Whether or not to format the result 1423 * @return int Forum reply count 1424 */ 1425 function bbp_get_forum_reply_count_hidden( $forum_id = 0, $total_count = true, $integer = false ) { 1394 1426 $forum_id = bbp_get_forum_id( $forum_id ); 1395 1427 $meta_key = empty( $total_count ) ? '_bbp_reply_count_hidden' : '_bbp_total_reply_count_hidden'; 1396 1428 $replies = (int) get_post_meta( $forum_id, $meta_key, true ); 1397 1429 $filter = ( true === $integer ) 1398 ? 'bbp_get_forum_reply_count_hidden_int'1399 : 'bbp_get_forum_reply_count_hidden';1430 ? 'bbp_get_forum_reply_count_hidden_int' 1431 : 'bbp_get_forum_reply_count_hidden'; 1400 1432 1401 1433 return apply_filters( $filter, $replies, $forum_id ); 1402 }1434 } 1403 1435 1404 1436 /** … … 1412 1444 echo bbp_get_forum_status( $forum_id ); 1413 1445 } 1414 /** 1415 * Return the status of the forum 1416 * 1417 * @since 2.0.0 bbPress (r2667) 1418 * 1419 * @param int $forum_id Optional. Forum id 1420 * @return string Status of forum 1421 */ 1422 function bbp_get_forum_status( $forum_id = 0 ) { 1446 1447 /** 1448 * Return the status of the forum 1449 * 1450 * @since 2.0.0 bbPress (r2667) 1451 * 1452 * @param int $forum_id Optional. Forum id 1453 * @return string Status of forum 1454 */ 1455 function bbp_get_forum_status( $forum_id = 0 ) { 1423 1456 $forum_id = bbp_get_forum_id( $forum_id ); 1424 1457 $status = get_post_meta( $forum_id, '_bbp_status', true ); … … 1426 1459 if ( empty( $status ) ) { 1427 1460 $status = 'open'; 1428 }1461 } 1429 1462 1430 1463 // Filter & return 1431 1464 return apply_filters( 'bbp_get_forum_status', $status, $forum_id ); 1432 }1465 } 1433 1466 1434 1467 /** … … 1442 1475 echo bbp_get_forum_visibility( $forum_id ); 1443 1476 } 1444 /** 1445 * Return the visibility of the forum 1446 * 1447 * @since 2.0.0 bbPress (r2997) 1448 * 1449 * @param int $forum_id Optional. Forum id 1450 * @return string Status of forum 1451 */ 1452 function bbp_get_forum_visibility( $forum_id = 0 ) { 1477 1478 /** 1479 * Return the visibility of the forum 1480 * 1481 * @since 2.0.0 bbPress (r2997) 1482 * 1483 * @param int $forum_id Optional. Forum id 1484 * @return string Status of forum 1485 */ 1486 function bbp_get_forum_visibility( $forum_id = 0 ) { 1453 1487 $forum_id = bbp_get_forum_id( $forum_id ); 1454 1488 $visibility = get_post_status( $forum_id ); … … 1456 1490 // Filter & return 1457 1491 return apply_filters( 'bbp_get_forum_visibility', $visibility, $forum_id ); 1458 }1492 } 1459 1493 1460 1494 /** … … 1468 1502 echo bbp_get_forum_type( $forum_id ); 1469 1503 } 1470 /** 1471 * Return the type of forum (category/forum/etc...) 1472 * 1473 * @since 2.1.0 bbPress (r3563) 1474 * 1475 * @param int $forum_id Optional. Forum id 1476 * @return bool Whether the forum is a category or not 1477 */ 1478 function bbp_get_forum_type( $forum_id = 0 ) { 1504 1505 /** 1506 * Return the type of forum (category/forum/etc...) 1507 * 1508 * @since 2.1.0 bbPress (r3563) 1509 * 1510 * @param int $forum_id Optional. Forum id 1511 * @return bool Whether the forum is a category or not 1512 */ 1513 function bbp_get_forum_type( $forum_id = 0 ) { 1479 1514 $forum_id = bbp_get_forum_id( $forum_id ); 1480 1515 $retval = get_post_meta( $forum_id, '_bbp_forum_type', true ); … … 1482 1517 if ( empty( $retval ) ) { 1483 1518 $retval = 'forum'; 1484 }1519 } 1485 1520 1486 1521 // Filter & return 1487 1522 return apply_filters( 'bbp_get_forum_type', $retval, $forum_id ); 1488 }1523 } 1489 1524 1490 1525 /** … … 1758 1793 echo bbp_get_forum_author_id( $forum_id ); 1759 1794 } 1760 /** 1761 * Return the author ID of the forum 1762 * 1763 * @since 2.1.0 bbPress (r3675) 1764 * 1765 * @param int $forum_id Optional. Forum id 1766 * 1767 * @return string Author of forum 1768 */ 1769 function bbp_get_forum_author_id( $forum_id = 0 ) { 1795 1796 /** 1797 * Return the author ID of the forum 1798 * 1799 * @since 2.1.0 bbPress (r3675) 1800 * 1801 * @param int $forum_id Optional. Forum id 1802 * 1803 * @return string Author of forum 1804 */ 1805 function bbp_get_forum_author_id( $forum_id = 0 ) { 1770 1806 $forum_id = bbp_get_forum_id( $forum_id ); 1771 1807 $author_id = get_post_field( 'post_author', $forum_id ); … … 1773 1809 // Filter & return 1774 1810 return (int) apply_filters( 'bbp_get_forum_author_id', (int) $author_id, $forum_id ); 1775 }1811 } 1776 1812 1777 1813 /** … … 1785 1821 echo bbp_get_forum_author_display_name( $forum_id ); 1786 1822 } 1787 /** 1788 * Return the author of the forum 1789 * 1790 * @since 2.1.0 bbPress (r3675) 1791 * 1792 * @param int $forum_id Optional. Forum id 1793 * @return string Author of forum 1794 */ 1795 function bbp_get_forum_author_display_name( $forum_id = 0 ) { 1823 1824 /** 1825 * Return the author of the forum 1826 * 1827 * @since 2.1.0 bbPress (r3675) 1828 * 1829 * @param int $forum_id Optional. Forum id 1830 * @return string Author of forum 1831 */ 1832 function bbp_get_forum_author_display_name( $forum_id = 0 ) { 1796 1833 $forum_id = bbp_get_forum_id( $forum_id ); 1797 1834 $author_id = bbp_get_forum_author_id( $forum_id ); … … 1800 1837 // Filter & return 1801 1838 return apply_filters( 'bbp_get_forum_author_display_name', $author, $forum_id, $author_id ); 1802 }1839 } 1803 1840 1804 1841 /** … … 1879 1916 echo bbp_get_forum_class( $forum_id, $classes ); 1880 1917 } 1881 /** 1882 * Return the row class of a forum 1883 * 1884 * @since 2.0.0 bbPress (r2667) 1885 * 1886 * @param int $forum_id Optional. Forum ID 1887 * @param array Extra classes you can pass when calling this function 1888 * @return string Row class of the forum 1889 */ 1890 function bbp_get_forum_class( $forum_id = 0, $classes = array() ) { 1918 1919 /** 1920 * Return the row class of a forum 1921 * 1922 * @since 2.0.0 bbPress (r2667) 1923 * 1924 * @param int $forum_id Optional. Forum ID 1925 * @param array Extra classes you can pass when calling this function 1926 * @return string Row class of the forum 1927 */ 1928 function bbp_get_forum_class( $forum_id = 0, $classes = array() ) { 1891 1929 $bbp = bbpress(); 1892 1930 $forum_id = bbp_get_forum_id( $forum_id ); … … 1897 1935 $classes = array_filter( (array) $classes ); 1898 1936 $count = isset( $bbp->forum_query->current_post ) 1899 ? (int) $bbp->forum_query->current_post1900 : 1;1937 ? (int) $bbp->forum_query->current_post 1938 : 1; 1901 1939 1902 1940 // Stripes 1903 1941 $even_odd = ( $count % 2 ) 1904 ? 'even'1905 : 'odd';1942 ? 'even' 1943 : 'odd'; 1906 1944 1907 1945 // User is moderator of forum 1908 1946 $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id ) 1909 ? 'forum-mod'1910 : '';1947 ? 'forum-mod' 1948 : ''; 1911 1949 1912 1950 // Is forum a non-postable category? 1913 1951 $category = bbp_is_forum_category( $forum_id ) 1914 ? 'status-category'1915 : '';1952 ? 'status-category' 1953 : ''; 1916 1954 1917 1955 // Forum has children? 1918 1956 $subs = bbp_get_forum_subforum_count( $forum_id ) 1919 ? 'bbp-has-subforums'1920 : '';1957 ? 'bbp-has-subforums' 1958 : ''; 1921 1959 1922 1960 // Forum has parent? 1923 1961 $parent = ! empty( $parent_id ) 1924 ? 'bbp-parent-forum-' . $parent_id1925 : '';1962 ? 'bbp-parent-forum-' . $parent_id 1963 : ''; 1926 1964 1927 1965 // Get forum classes 1928 1966 $forum_classes = array( 1929 'loop-item-' . $count,1930 'bbp-forum-status-' . $status,1931 'bbp-forum-visibility-' . $visibility,1932 $even_odd,1933 $forum_moderator,1934 $category,1935 $subs,1936 $parent1967 'loop-item-' . $count, 1968 'bbp-forum-status-' . $status, 1969 'bbp-forum-visibility-' . $visibility, 1970 $even_odd, 1971 $forum_moderator, 1972 $category, 1973 $subs, 1974 $parent 1937 1975 ); 1938 1976 … … 1946 1984 // Return 1947 1985 return 'class="' . implode( ' ', $new_classes ) . '"'; 1948 }1986 } 1949 1987 1950 1988 /** Single Forum **************************************************************/ … … 1961 1999 echo bbp_get_single_forum_description( $args ); 1962 2000 } 1963 /** 1964 * Return a fancy description of the current forum, including total 1965 * topics, total replies, and last activity. 1966 * 1967 * @since 2.0.0 bbPress (r2860) 1968 * 1969 * @param array $args This function supports these arguments: 1970 * - forum_id: Forum id 1971 * - before: Before the text 1972 * - after: After the text 1973 * - size: Size of the avatar 1974 * @return string Filtered forum description 1975 */ 1976 function bbp_get_single_forum_description( $args = array() ) { 2001 2002 /** 2003 * Return a fancy description of the current forum, including total 2004 * topics, total replies, and last activity. 2005 * 2006 * @since 2.0.0 bbPress (r2860) 2007 * 2008 * @param array $args This function supports these arguments: 2009 * - forum_id: Forum id 2010 * - before: Before the text 2011 * - after: After the text 2012 * - size: Size of the avatar 2013 * @return string Filtered forum description 2014 */ 2015 function bbp_get_single_forum_description( $args = array() ) { 1977 2016 1978 2017 // Parse arguments against default values 1979 2018 $r = bbp_parse_args( $args, array( 1980 'forum_id' => 0,1981 'before' => '<div class="bbp-template-notice info"><ul><li class="bbp-forum-description">',1982 'after' => '</li></ul></div>',1983 'size' => 14,1984 'feed' => true2019 'forum_id' => 0, 2020 'before' => '<div class="bbp-template-notice info"><ul><li class="bbp-forum-description">', 2021 'after' => '</li></ul></div>', 2022 'size' => 14, 2023 'feed' => true 1985 2024 ), 'get_single_forum_description' ); 1986 2025 1987 // Validate forum_id 1988 $forum_id = bbp_get_forum_id( $r['forum_id'] ); 1989 1990 // Unhook the 'view all' query var adder 1991 remove_filter( 'bbp_get_forum_permalink', 'bbp_add_view_all' ); 1992 1993 // Get some forum data 1994 $tc_int = bbp_get_forum_topic_count( $forum_id, true, true ); 1995 $rc_int = bbp_get_forum_reply_count( $forum_id, true, true ); 1996 $topic_count = bbp_get_forum_topic_count( $forum_id, true, false ); 1997 $reply_count = bbp_get_forum_reply_count( $forum_id, true, false ); 1998 $last_active = bbp_get_forum_last_active_id( $forum_id ); 1999 2000 // Has replies 2001 if ( ! empty( $reply_count ) ) { 2002 $reply_text = sprintf( _n( '%s reply', '%s replies', $rc_int, 'bbpress' ), $reply_count ); 2003 } 2004 2005 // Forum has active data 2006 if ( ! empty( $last_active ) ) { 2007 $topic_text = bbp_get_forum_topics_link( $forum_id ); 2008 $time_since = bbp_get_forum_freshness_link( $forum_id ); 2009 $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_active, 'size' => $r['size'] ) ); 2026 // Validate forum_id 2027 $forum_id = bbp_get_forum_id( $r['forum_id'] ); 2028 2029 // Unhook the 'view all' query var adder 2030 remove_filter( 'bbp_get_forum_permalink', 'bbp_add_view_all' ); 2031 2032 // Get some forum data 2033 $tc_int = bbp_get_forum_topic_count( $forum_id, true, true ); 2034 $rc_int = bbp_get_forum_reply_count( $forum_id, true, true ); 2035 $topic_count = bbp_get_forum_topic_count( $forum_id, true, false ); 2036 $reply_count = bbp_get_forum_reply_count( $forum_id, true, false ); 2037 $last_active = bbp_get_forum_last_active_id( $forum_id ); 2038 2039 // Has replies 2040 if ( ! empty( $reply_count ) ) { 2041 /* translators: %s: Number of replies */ 2042 $reply_text = sprintf( _n( '%s reply', '%s replies', $rc_int, 'bbpress' ), $reply_count ); 2043 } 2044 2045 // Forum has active data 2046 if ( ! empty( $last_active ) ) { 2047 $topic_text = bbp_get_forum_topics_link( $forum_id ); 2048 $time_since = bbp_get_forum_freshness_link( $forum_id ); 2049 $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_active, 'size' => $r['size'] ) ); 2010 2050 2011 2051 // Forum has no last active data 2012 2052 } else { 2013 $topic_text = sprintf( _n( '%s topic', '%s topics', $tc_int, 'bbpress' ), $topic_count ); 2014 } 2015 2016 // Forum has active data 2017 if ( ! empty( $last_active ) ) { 2018 2019 // Has replies 2020 if ( ! empty( $reply_count ) ) { 2021 $retstr = bbp_is_forum_category( $forum_id ) 2022 ? sprintf( esc_html__( 'This category has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by ) 2023 : sprintf( esc_html__( 'This forum has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by ); 2053 /* translators: %s: Number of topics */ 2054 $topic_text = sprintf( _n( '%s topic', '%s topics', $tc_int, 'bbpress' ), $topic_count ); 2055 } 2056 2057 // Forum has active data 2058 if ( ! empty( $last_active ) ) { 2059 2060 // Has replies 2061 if ( ! empty( $reply_count ) ) { 2062 $retstr = bbp_is_forum_category( $forum_id ) 2063 /* translators: 1: Topics link, 2: Replies text, 3: Last update time, 4: Author link */ 2064 ? sprintf( esc_html__( 'This category has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by ) 2065 /* translators: 1: Topics link, 2: Replies text, 3: Last update time, 4: Author link */ 2066 : sprintf( esc_html__( 'This forum has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $topic_text, $reply_text, $time_since, $last_updated_by ); 2024 2067 2025 2068 // Only has topics 2026 2069 } else { 2070 $retstr = bbp_is_forum_category( $forum_id ) 2071 /* translators: 1: Topics link, 2: Last update time, 3: Author link */ 2072 ? sprintf( esc_html__( 'This category has %1$s, and was last updated %2$s by %3$s.', 'bbpress' ), $topic_text, $time_since, $last_updated_by ) 2073 /* translators: 1: Topics link, 2: Last update time, 3: Author link */ 2074 : sprintf( esc_html__( 'This forum has %1$s, and was last updated %2$s by %3$s.', 'bbpress' ), $topic_text, $time_since, $last_updated_by ); 2075 } 2076 2077 // Forum has no last active data (but does have topics & replies) 2078 } elseif ( ! empty( $reply_count ) ) { 2027 2079 $retstr = bbp_is_forum_category( $forum_id ) 2028 ? sprintf( esc_html__( 'This category has %1$s, and was last updated %2$s by %3$s.', 'bbpress' ), $topic_text, $time_since, $last_updated_by ) 2029 : sprintf( esc_html__( 'This forum has %1$s, and was last updated %2$s by %3$s.', 'bbpress' ), $topic_text, $time_since, $last_updated_by ); 2030 } 2031 2032 // Forum has no last active data (but does have topics & replies) 2033 } elseif ( ! empty( $reply_count ) ) { 2034 $retstr = bbp_is_forum_category( $forum_id ) 2035 ? sprintf( esc_html__( 'This category has %1$s and %2$s.', 'bbpress' ), $topic_text, $reply_text ) 2036 : sprintf( esc_html__( 'This forum has %1$s and %2$s.', 'bbpress' ), $topic_text, $reply_text ); 2037 2038 // Forum has no last active data or replies (but does have topics) 2080 /* translators: 1: Topics link, 2: Replies text */ 2081 ? sprintf( esc_html__( 'This category has %1$s and %2$s.', 'bbpress' ), $topic_text, $reply_text ) 2082 /* translators: 1: Topics link, 2: Replies text */ 2083 : sprintf( esc_html__( 'This forum has %1$s and %2$s.', 'bbpress' ), $topic_text, $reply_text ); 2084 2085 // Forum has no last active data or replies (but does have topics) 2039 2086 } elseif ( ! empty( $topic_count ) ) { 2040 $retstr = bbp_is_forum_category( $forum_id ) 2041 ? sprintf( esc_html__( 'This category has %1$s.', 'bbpress' ), $topic_text ) 2042 : sprintf( esc_html__( 'This forum has %1$s.', 'bbpress' ), $topic_text ); 2087 $retstr = bbp_is_forum_category( $forum_id ) 2088 /* translators: 1: Topics link */ 2089 ? sprintf( esc_html__( 'This category has %1$s.', 'bbpress' ), $topic_text ) 2090 /* translators: 1: Topics link */ 2091 : sprintf( esc_html__( 'This forum has %1$s.', 'bbpress' ), $topic_text ); 2043 2092 2044 2093 // Forum is empty 2045 2094 } else { 2046 $retstr = esc_html__( 'This forum is empty.', 'bbpress' );2047 } 2048 2049 // Add the 'view all' filter back2050 add_filter( 'bbp_get_forum_permalink', 'bbp_add_view_all' );2051 2052 // Combine the elements together2053 $retstr = $r['before'] . $retstr . $r['after'];2054 2055 // Filter & return2056 return apply_filters( 'bbp_get_single_forum_description', $retstr, $r, $args );2057 }2095 $retstr = esc_html__( 'This forum is empty.', 'bbpress' ); 2096 } 2097 2098 // Add the 'view all' filter back 2099 add_filter( 'bbp_get_forum_permalink', 'bbp_add_view_all' ); 2100 2101 // Combine the elements together 2102 $retstr = $r['before'] . $retstr . $r['after']; 2103 2104 // Filter & return 2105 return apply_filters( 'bbp_get_single_forum_description', $retstr, $r, $args ); 2106 } 2058 2107 2059 2108 /** Forms *********************************************************************/ … … 2067 2116 echo bbp_get_form_forum_title(); 2068 2117 } 2069 /** 2070 * Return the value of forum title field 2071 * 2072 * @since 2.1.0 bbPress (r3551) 2073 * 2074 * @return string Value of forum title field 2075 */ 2076 function bbp_get_form_forum_title() { 2118 2119 /** 2120 * Return the value of forum title field 2121 * 2122 * @since 2.1.0 bbPress (r3551) 2123 * 2124 * @return string Value of forum title field 2125 */ 2126 function bbp_get_form_forum_title() { 2077 2127 2078 2128 // Get _POST data … … 2080 2130 $forum_title = wp_unslash( $_POST['bbp_forum_title'] ); 2081 2131 2082 // Get edit data2083 } elseif ( bbp_is_forum_edit() ) {2132 // Get edit data 2133 } elseif ( bbp_is_forum_edit() ) { 2084 2134 $forum_title = bbp_get_global_post_field( 'post_title', 'raw' ); 2085 2135 2086 // No data2087 } else {2136 // No data 2137 } else { 2088 2138 $forum_title = ''; 2089 }2139 } 2090 2140 2091 2141 // Filter & return 2092 2142 return apply_filters( 'bbp_get_form_forum_title', $forum_title ); 2093 }2143 } 2094 2144 2095 2145 /** … … 2101 2151 echo bbp_get_form_forum_content(); 2102 2152 } 2103 /** 2104 * Return the value of forum content field 2105 * 2106 * @since 2.1.0 bbPress (r3551) 2107 * 2108 * @return string Value of forum content field 2109 */ 2110 function bbp_get_form_forum_content() { 2153 2154 /** 2155 * Return the value of forum content field 2156 * 2157 * @since 2.1.0 bbPress (r3551) 2158 * 2159 * @return string Value of forum content field 2160 */ 2161 function bbp_get_form_forum_content() { 2111 2162 2112 2163 // Get _POST data … … 2114 2165 $forum_content = wp_unslash( $_POST['bbp_forum_content'] ); 2115 2166 2116 // Get edit data2117 } elseif ( bbp_is_forum_edit() ) {2167 // Get edit data 2168 } elseif ( bbp_is_forum_edit() ) { 2118 2169 $forum_content = bbp_get_global_post_field( 'post_content', 'raw' ); 2119 2170 2120 // No data2121 } else {2171 // No data 2172 } else { 2122 2173 $forum_content = ''; 2123 }2174 } 2124 2175 2125 2176 // Filter & return 2126 2177 return apply_filters( 'bbp_get_form_forum_content', $forum_content ); 2127 }2178 } 2128 2179 2129 2180 /** … … 2135 2186 echo bbp_get_form_forum_moderators(); 2136 2187 } 2137 /** 2138 * Return value of forum moderators field 2139 * 2140 * @since 2.6.0 bbPress (r5837) 2141 * 2142 * @return string Value of forum mods field 2143 */ 2144 function bbp_get_form_forum_moderators() { 2188 2189 /** 2190 * Return value of forum moderators field 2191 * 2192 * @since 2.6.0 bbPress (r5837) 2193 * 2194 * @return string Value of forum mods field 2195 */ 2196 function bbp_get_form_forum_moderators() { 2145 2197 2146 2198 // Default return value … … 2151 2203 $forum_mods = wp_unslash( $_POST['bbp_moderators'] ); 2152 2204 2153 // Get edit data2154 } elseif ( bbp_is_single_forum() || bbp_is_forum_edit() ) {2205 // Get edit data 2206 } elseif ( bbp_is_single_forum() || bbp_is_forum_edit() ) { 2155 2207 2156 2208 // Get the forum ID … … 2168 2220 if ( ! empty( $user_nicenames ) ) { 2169 2221 $forum_mods = implode( ', ', wp_list_pluck( $user_nicenames, 'user_nicename' ) ); 2170 }2171 2222 } 2172 2223 } 2173 2224 } 2225 } 2174 2226 2175 2227 // Filter & return 2176 2228 return apply_filters( 'bbp_get_form_forum_moderators', $forum_mods ); 2177 }2229 } 2178 2230 2179 2231 /** … … 2185 2237 echo bbp_get_form_forum_parent(); 2186 2238 } 2187 /** 2188 * Return value of forum parent 2189 * 2190 * @since 2.1.0 bbPress (r3551) 2191 * 2192 * @return string Value of topic content field 2193 */ 2194 function bbp_get_form_forum_parent() { 2239 2240 /** 2241 * Return value of forum parent 2242 * 2243 * @since 2.1.0 bbPress (r3551) 2244 * 2245 * @return string Value of topic content field 2246 */ 2247 function bbp_get_form_forum_parent() { 2195 2248 2196 2249 // Get _POST data … … 2198 2251 $forum_parent = (int) $_POST['bbp_forum_id']; 2199 2252 2200 // Get edit data2201 } elseif ( bbp_is_forum_edit() ) {2253 // Get edit data 2254 } elseif ( bbp_is_forum_edit() ) { 2202 2255 $forum_parent = bbp_get_forum_parent_id(); 2203 2256 2204 // No data2205 } else {2257 // No data 2258 } else { 2206 2259 $forum_parent = 0; 2207 }2260 } 2208 2261 2209 2262 // Filter & return 2210 2263 return apply_filters( 'bbp_get_form_forum_parent', $forum_parent ); 2211 }2264 } 2212 2265 2213 2266 /** … … 2219 2272 echo bbp_get_form_forum_type(); 2220 2273 } 2221 /** 2222 * Return value of forum type 2223 * 2224 * @since 2.1.0 bbPress (r3563) 2225 * 2226 * @return string Value of topic content field 2227 */ 2228 function bbp_get_form_forum_type() { 2274 2275 /** 2276 * Return value of forum type 2277 * 2278 * @since 2.1.0 bbPress (r3563) 2279 * 2280 * @return string Value of topic content field 2281 */ 2282 function bbp_get_form_forum_type() { 2229 2283 2230 2284 // Get _POST data … … 2232 2286 $forum_type = sanitize_key( $_POST['bbp_forum_type'] ); 2233 2287 2234 // Get edit data2235 } elseif ( bbp_is_forum_edit() ) {2288 // Get edit data 2289 } elseif ( bbp_is_forum_edit() ) { 2236 2290 $forum_type = bbp_get_forum_type(); 2237 2291 2238 // No data2239 } else {2292 // No data 2293 } else { 2240 2294 $forum_type = 'forum'; 2241 }2295 } 2242 2296 2243 2297 // Filter & return 2244 2298 return apply_filters( 'bbp_get_form_forum_type', $forum_type ); 2245 }2299 } 2246 2300 2247 2301 /** … … 2253 2307 echo bbp_get_form_forum_visibility(); 2254 2308 } 2255 /** 2256 * Return value of forum visibility 2257 * 2258 * @since 2.1.0 bbPress (r3563) 2259 * 2260 * @return string Value of topic content field 2261 */ 2262 function bbp_get_form_forum_visibility() { 2309 2310 /** 2311 * Return value of forum visibility 2312 * 2313 * @since 2.1.0 bbPress (r3563) 2314 * 2315 * @return string Value of topic content field 2316 */ 2317 function bbp_get_form_forum_visibility() { 2263 2318 2264 2319 // Get _POST data … … 2266 2321 $forum_visibility = sanitize_key( $_POST['bbp_forum_visibility'] ); 2267 2322 2268 // Get edit data2269 } elseif ( bbp_is_forum_edit() ) {2323 // Get edit data 2324 } elseif ( bbp_is_forum_edit() ) { 2270 2325 $forum_visibility = bbp_get_forum_visibility(); 2271 2326 2272 // No data2273 } else {2327 // No data 2328 } else { 2274 2329 $forum_visibility = bbpress()->public_status_id; 2275 }2330 } 2276 2331 2277 2332 // Filter & return 2278 2333 return apply_filters( 'bbp_get_form_forum_visibility', $forum_visibility ); 2279 }2334 } 2280 2335 2281 2336 /** … … 2287 2342 echo bbp_get_form_forum_subscribed(); 2288 2343 } 2289 /** 2290 * Return checked value of forum subscription 2291 * 2292 * @since 2.5.0 bbPress (r5156) 2293 * 2294 * @return string Checked value of forum subscription 2295 */ 2296 function bbp_get_form_forum_subscribed() { 2344 2345 /** 2346 * Return checked value of forum subscription 2347 * 2348 * @since 2.5.0 bbPress (r5156) 2349 * 2350 * @return string Checked value of forum subscription 2351 */ 2352 function bbp_get_form_forum_subscribed() { 2297 2353 2298 2354 // Default value … … 2303 2359 $forum_subscribed = (bool) $_POST['bbp_forum_subscription']; 2304 2360 2305 // Get edit data2306 } elseif ( bbp_is_forum_edit() || bbp_is_reply_edit() ) {2361 // Get edit data 2362 } elseif ( bbp_is_forum_edit() || bbp_is_reply_edit() ) { 2307 2363 $post_author = (int) bbp_get_global_post_field( 'post_author', 'raw' ); 2308 2364 $forum_subscribed = bbp_is_user_subscribed( $post_author, bbp_get_forum_id() ); 2309 2365 2310 // Get current status2311 } elseif ( bbp_is_single_forum() ) {2366 // Get current status 2367 } elseif ( bbp_is_single_forum() ) { 2312 2368 $forum_subscribed = bbp_is_user_subscribed( bbp_get_current_user_id(), bbp_get_forum_id() ); 2313 }2369 } 2314 2370 2315 2371 // Get checked output … … 2318 2374 // Filter & return 2319 2375 return apply_filters( 'bbp_get_form_forum_subscribed', $checked, $forum_subscribed ); 2320 }2376 } 2321 2377 2322 2378 /** Form Dropdowns ************************************************************/ … … 2336 2392 echo bbp_get_form_forum_type_dropdown( $args ); 2337 2393 } 2338 /** 2339 * Return the forum type dropdown 2340 * 2341 * @since 2.1.0 bbPress (r3563) 2342 * 2343 * @param $args This function supports these arguments: 2344 * - select_id: Select id. Defaults to bbp_forum_type 2345 * - tab: Deprecated. Tabindex 2346 * - forum_id: Forum id 2347 * - selected: Override the selected option 2348 * @return string HTML select list for selecting forum type 2349 */ 2350 function bbp_get_form_forum_type_dropdown( $args = array() ) { 2394 2395 /** 2396 * Return the forum type dropdown 2397 * 2398 * @since 2.1.0 bbPress (r3563) 2399 * 2400 * @param $args This function supports these arguments: 2401 * - select_id: Select id. Defaults to bbp_forum_type 2402 * - tab: Deprecated. Tabindex 2403 * - forum_id: Forum id 2404 * - selected: Override the selected option 2405 * @return string HTML select list for selecting forum type 2406 */ 2407 function bbp_get_form_forum_type_dropdown( $args = array() ) { 2351 2408 2352 2409 // Backpat for handling passing of a forum ID as integer … … 2354 2411 $forum_id = (int) $args; 2355 2412 $args = array(); 2356 } else {2413 } else { 2357 2414 $forum_id = 0; 2358 }2415 } 2359 2416 2360 2417 // Parse arguments against default values 2361 2418 $r = bbp_parse_args( $args, array( 2362 'select_id' => 'bbp_forum_type',2363 'select_class' => 'bbp_dropdown',2364 'tab' => false,2365 'forum_id' => $forum_id,2366 'selected' => false2419 'select_id' => 'bbp_forum_type', 2420 'select_class' => 'bbp_dropdown', 2421 'tab' => false, 2422 'forum_id' => $forum_id, 2423 'selected' => false 2367 2424 ), 'forum_type_select' ); 2368 2425 2369 // No specific selected value passed2370 if ( empty( $r['selected'] ) ) {2371 2372 // Post value is passed2373 if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {2374 $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );2426 // No specific selected value passed 2427 if ( empty( $r['selected'] ) ) { 2428 2429 // Post value is passed 2430 if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) { 2431 $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] ); 2375 2432 2376 2433 // No Post value was passed 2377 2434 } else { 2378 2435 2379 // Edit topic2380 if ( bbp_is_forum_edit() ) {2381 $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );2382 $r['selected'] = bbp_get_forum_type( $r['forum_id'] );2436 // Edit topic 2437 if ( bbp_is_forum_edit() ) { 2438 $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] ); 2439 $r['selected'] = bbp_get_forum_type( $r['forum_id'] ); 2383 2440 2384 2441 // New topic 2385 2442 } else { 2386 $r['selected'] = bbp_get_public_status_id();2443 $r['selected'] = bbp_get_public_status_id(); 2387 2444 } 2388 }2389 } 2390 2391 // Start an output buffer, we'll finish it after the select loop2392 ob_start(); ?>2393 2394 <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>>2395 2396 <?php foreach ( bbp_get_forum_types( $r['forum_id'] ) as $key => $label ) : ?>2397 2398 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>2399 2400 <?php endforeach; ?>2401 2402 </select>2403 2404 <?php2405 2406 // Filter & return2407 return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args );2408 }2445 } 2446 } 2447 2448 // Start an output buffer, we'll finish it after the select loop 2449 ob_start(); ?> 2450 2451 <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>> 2452 2453 <?php foreach ( bbp_get_forum_types( $r['forum_id'] ) as $key => $label ) : ?> 2454 2455 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option> 2456 2457 <?php endforeach; ?> 2458 2459 </select> 2460 2461 <?php 2462 2463 // Filter & return 2464 return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args ); 2465 } 2409 2466 2410 2467 /** … … 2422 2479 echo bbp_get_form_forum_status_dropdown( $args ); 2423 2480 } 2424 /** 2425 * Return the forum status dropdown 2426 * 2427 * @since 2.1.0 bbPress (r3563) 2428 * 2429 * @param $args This function supports these arguments: 2430 * - select_id: Select id. Defaults to bbp_forum_status 2431 * - tab: Deprecated. Tabindex 2432 * - forum_id: Forum id 2433 * - selected: Override the selected option 2434 * @return string HTML select list for selecting forum status 2435 */ 2436 function bbp_get_form_forum_status_dropdown( $args = array() ) { 2481 2482 /** 2483 * Return the forum status dropdown 2484 * 2485 * @since 2.1.0 bbPress (r3563) 2486 * 2487 * @param $args This function supports these arguments: 2488 * - select_id: Select id. Defaults to bbp_forum_status 2489 * - tab: Deprecated. Tabindex 2490 * - forum_id: Forum id 2491 * - selected: Override the selected option 2492 * @return string HTML select list for selecting forum status 2493 */ 2494 function bbp_get_form_forum_status_dropdown( $args = array() ) { 2437 2495 2438 2496 // Backpat for handling passing of a forum ID … … 2440 2498 $forum_id = (int) $args; 2441 2499 $args = array(); 2442 } else {2500 } else { 2443 2501 $forum_id = 0; 2444 }2502 } 2445 2503 2446 2504 // Parse arguments against default values 2447 2505 $r = bbp_parse_args( $args, array( 2448 'select_id' => 'bbp_forum_status',2449 'select_class' => 'bbp_dropdown',2450 'tab' => false,2451 'forum_id' => $forum_id,2452 'selected' => false2506 'select_id' => 'bbp_forum_status', 2507 'select_class' => 'bbp_dropdown', 2508 'tab' => false, 2509 'forum_id' => $forum_id, 2510 'selected' => false 2453 2511 ), 'forum_status_select' ); 2454 2512 2455 // No specific selected value passed2456 if ( empty( $r['selected'] ) ) {2457 2458 // Post value is passed2459 if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {2460 $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );2513 // No specific selected value passed 2514 if ( empty( $r['selected'] ) ) { 2515 2516 // Post value is passed 2517 if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) { 2518 $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] ); 2461 2519 2462 2520 // No Post value was passed 2463 2521 } else { 2464 2522 2465 // Edit topic2466 if ( bbp_is_forum_edit() ) {2467 $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );2468 $r['selected'] = bbp_get_forum_status( $r['forum_id'] );2523 // Edit topic 2524 if ( bbp_is_forum_edit() ) { 2525 $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] ); 2526 $r['selected'] = bbp_get_forum_status( $r['forum_id'] ); 2469 2527 2470 2528 // New topic 2471 2529 } else { 2472 $r['selected'] = bbp_get_public_status_id();2530 $r['selected'] = bbp_get_public_status_id(); 2473 2531 } 2474 }2475 } 2476 2477 // Start an output buffer, we'll finish it after the select loop2478 ob_start(); ?>2479 2480 <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>>2481 2482 <?php foreach ( bbp_get_forum_statuses( $r['forum_id'] ) as $key => $label ) : ?>2483 2484 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>2485 2486 <?php endforeach; ?>2487 2488 </select>2489 2490 <?php2491 2492 // Filter & return2493 return apply_filters( 'bbp_get_form_forum_status_dropdown', ob_get_clean(), $r, $args );2494 }2532 } 2533 } 2534 2535 // Start an output buffer, we'll finish it after the select loop 2536 ob_start(); ?> 2537 2538 <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>> 2539 2540 <?php foreach ( bbp_get_forum_statuses( $r['forum_id'] ) as $key => $label ) : ?> 2541 2542 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option> 2543 2544 <?php endforeach; ?> 2545 2546 </select> 2547 2548 <?php 2549 2550 // Filter & return 2551 return apply_filters( 'bbp_get_form_forum_status_dropdown', ob_get_clean(), $r, $args ); 2552 } 2495 2553 2496 2554 /** … … 2508 2566 echo bbp_get_form_forum_visibility_dropdown( $args ); 2509 2567 } 2510 /** 2511 * Return the forum visibility dropdown 2512 * 2513 * @since 2.1.0 bbPress (r3563) 2514 * 2515 * @param $args This function supports these arguments: 2516 * - select_id: Select id. Defaults to bbp_forum_visibility 2517 * - tab: Deprecated. Tabindex 2518 * - forum_id: Forum id 2519 * - selected: Override the selected option 2520 * @return string HTML select list for selecting forum visibility 2521 */ 2522 function bbp_get_form_forum_visibility_dropdown( $args = array() ) { 2568 2569 /** 2570 * Return the forum visibility dropdown 2571 * 2572 * @since 2.1.0 bbPress (r3563) 2573 * 2574 * @param $args This function supports these arguments: 2575 * - select_id: Select id. Defaults to bbp_forum_visibility 2576 * - tab: Deprecated. Tabindex 2577 * - forum_id: Forum id 2578 * - selected: Override the selected option 2579 * @return string HTML select list for selecting forum visibility 2580 */ 2581 function bbp_get_form_forum_visibility_dropdown( $args = array() ) { 2523 2582 2524 2583 // Backpat for handling passing of a forum ID … … 2526 2585 $forum_id = (int) $args; 2527 2586 $args = array(); 2528 } else {2587 } else { 2529 2588 $forum_id = 0; 2530 }2589 } 2531 2590 2532 2591 // Parse arguments against default values 2533 2592 $r = bbp_parse_args( $args, array( 2534 'select_id' => 'bbp_forum_visibility',2535 'select_class' => 'bbp_dropdown',2536 'tab' => false,2537 'forum_id' => $forum_id,2538 'selected' => false2593 'select_id' => 'bbp_forum_visibility', 2594 'select_class' => 'bbp_dropdown', 2595 'tab' => false, 2596 'forum_id' => $forum_id, 2597 'selected' => false 2539 2598 ), 'forum_type_select' ); 2540 2599 2541 // No specific selected value passed2542 if ( empty( $r['selected'] ) ) {2543 2544 // Post value is passed2545 if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {2546 $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );2600 // No specific selected value passed 2601 if ( empty( $r['selected'] ) ) { 2602 2603 // Post value is passed 2604 if ( bbp_is_forum_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) { 2605 $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] ); 2547 2606 2548 2607 // No Post value was passed 2549 2608 } else { 2550 2609 2551 // Edit topic2552 if ( bbp_is_forum_edit() ) {2553 $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] );2554 $r['selected'] = bbp_get_forum_visibility( $r['forum_id'] );2610 // Edit topic 2611 if ( bbp_is_forum_edit() ) { 2612 $r['forum_id'] = bbp_get_forum_id( $r['forum_id'] ); 2613 $r['selected'] = bbp_get_forum_visibility( $r['forum_id'] ); 2555 2614 2556 2615 // New topic 2557 2616 } else { 2558 $r['selected'] = bbp_get_public_status_id();2617 $r['selected'] = bbp_get_public_status_id(); 2559 2618 } 2560 }2561 } 2562 2563 // Start an output buffer, we'll finish it after the select loop2564 ob_start(); ?>2565 2566 <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>>2567 2568 <?php foreach ( bbp_get_forum_visibilities( $r['forum_id'] ) as $key => $label ) : ?>2569 2570 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>2571 2572 <?php endforeach; ?>2573 2574 </select>2575 2576 <?php2577 2578 // Filter & return2579 return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args );2580 }2619 } 2620 } 2621 2622 // Start an output buffer, we'll finish it after the select loop 2623 ob_start(); ?> 2624 2625 <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>> 2626 2627 <?php foreach ( bbp_get_forum_visibilities( $r['forum_id'] ) as $key => $label ) : ?> 2628 2629 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option> 2630 2631 <?php endforeach; ?> 2632 2633 </select> 2634 2635 <?php 2636 2637 // Filter & return 2638 return apply_filters( 'bbp_get_form_forum_type_dropdown', ob_get_clean(), $r, $args ); 2639 } 2581 2640 2582 2641 /** … … 2624 2683 echo bbp_get_forum_topics_feed_link( $forum_id ); 2625 2684 } 2626 /** 2627 * Retrieve the link for the forum feed 2628 * 2629 * @since 2.0.0 bbPress (r3172) 2630 * 2631 * @param int $forum_id Optional. Forum ID. 2632 * 2633 * @return string 2634 */ 2635 function bbp_get_forum_topics_feed_link( $forum_id = 0 ) { 2685 2686 /** 2687 * Retrieve the link for the forum feed 2688 * 2689 * @since 2.0.0 bbPress (r3172) 2690 * 2691 * @param int $forum_id Optional. Forum ID. 2692 * 2693 * @return string 2694 */ 2695 function bbp_get_forum_topics_feed_link( $forum_id = 0 ) { 2636 2696 2637 2697 // Validate forum id … … 2652 2712 2653 2713 // Unpretty permalinks 2654 } else {2714 } else { 2655 2715 $url = home_url( add_query_arg( array( 2656 'feed' => 'rss2',2657 bbp_get_forum_post_type() => get_post_field( 'post_name', $forum_id )2716 'feed' => 'rss2', 2717 bbp_get_forum_post_type() => get_post_field( 'post_name', $forum_id ) 2658 2718 ) ) ); 2659 }2719 } 2660 2720 2661 2721 $link = '<a href="' . esc_url( $url ) . '" class="bbp-forum-rss-link topics"><span>' . esc_attr__( 'Topics', 'bbpress' ) . '</span></a>'; 2662 }2722 } 2663 2723 2664 2724 // Filter & return 2665 2725 return apply_filters( 'bbp_get_forum_topics_feed_link', $link, $url, $forum_id ); 2666 }2726 } 2667 2727 2668 2728 /** … … 2676 2736 echo bbp_get_forum_replies_feed_link( $forum_id ); 2677 2737 } 2678 /** 2679 * Retrieve the link for the forum replies feed 2680 * 2681 * @since 2.0.0 bbPress (r3172) 2682 * 2683 * @param int $forum_id Optional. Forum ID. 2684 * 2685 * @return string 2686 */ 2687 function bbp_get_forum_replies_feed_link( $forum_id = 0 ) { 2738 2739 /** 2740 * Retrieve the link for the forum replies feed 2741 * 2742 * @since 2.0.0 bbPress (r3172) 2743 * 2744 * @param int $forum_id Optional. Forum ID. 2745 * 2746 * @return string 2747 */ 2748 function bbp_get_forum_replies_feed_link( $forum_id = 0 ) { 2688 2749 2689 2750 // Validate forum id … … 2704 2765 $url = add_query_arg( array( 'type' => 'reply' ), $url ); 2705 2766 2706 // Unpretty permalinks2707 } else {2767 // Unpretty permalinks 2768 } else { 2708 2769 $url = home_url( add_query_arg( array( 2709 'type' => 'reply',2710 'feed' => 'rss2',2711 bbp_get_forum_post_type() => get_post_field( 'post_name', $forum_id )2770 'type' => 'reply', 2771 'feed' => 'rss2', 2772 bbp_get_forum_post_type() => get_post_field( 'post_name', $forum_id ) 2712 2773 ) ) ); 2713 }2774 } 2714 2775 2715 2776 $link = '<a href="' . esc_url( $url ) . '" class="bbp-forum-rss-link replies"><span>' . esc_html__( 'Replies', 'bbpress' ) . '</span></a>'; 2716 }2777 } 2717 2778 2718 2779 // Filter & return 2719 2780 return apply_filters( 'bbp_get_forum_replies_feed_link', $link, $url, $forum_id ); 2720 }2781 } -
trunk/src/includes/replies/functions.php
r7357 r7360 507 507 // WP_Error 508 508 } elseif ( is_wp_error( $reply_id ) ) { 509 /* translators: %s: Error message(s) */ 509 510 bbp_add_error( 'bbp_reply_error', sprintf( __( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ), $reply_id->get_error_message() ) ); 510 511 … … 824 825 825 826 } else { 826 $append_error = ( is_wp_error( $reply_id ) && $reply_id->get_error_message() ) ? $reply_id->get_error_message() . ' ' : ''; 827 $append_error = ( is_wp_error( $reply_id ) && $reply_id->get_error_message() ) 828 ? $reply_id->get_error_message() . ' ' 829 : ''; 830 831 /* translators: %s: Error message(s) */ 827 832 bbp_add_error( 'bbp_reply_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found with your reply: %s. Please try again.', 'bbpress' ) ), $append_error ); 828 833 } … … 2241 2246 <description> 2242 2247 <![CDATA[ 2243 <p><?php printf( __( 'Replies: %s', 'bbpress' ), bbp_get_topic_reply_count() ); ?></p> 2248 <p> 2249 <?php 2250 printf( 2251 /* translators: %s: Number of replies */ 2252 __( 'Replies: %s', 'bbpress' ), 2253 bbp_get_topic_reply_count() 2254 ); 2255 ?> 2256 </p> 2244 2257 <?php bbp_topic_content(); ?> 2245 2258 ]]> -
trunk/src/includes/replies/template.php
r7359 r7360 22 22 echo bbp_get_reply_post_type(); 23 23 } 24 /** 25 * Return the unique id of the custom post type for replies 26 * 27 * @since 2.0.0 bbPress (r2857) 28 * 29 * post type id 30 * @return string The unique reply post type id 31 */ 32 function bbp_get_reply_post_type() { 24 25 /** 26 * Return the unique id of the custom post type for replies 27 * 28 * @since 2.0.0 bbPress (r2857) 29 * 30 * post type id 31 * @return string The unique reply post type id 32 */ 33 function bbp_get_reply_post_type() { 33 34 34 35 // Filter & return 35 36 return apply_filters( 'bbp_get_reply_post_type', bbpress()->reply_post_type ); 36 }37 } 37 38 38 39 /** … … 302 303 echo bbp_get_reply_id( $reply_id ); 303 304 } 304 /** 305 * Return the id of the reply in a replies loop 306 * 307 * @since 2.0.0 bbPress (r2553) 308 * 309 * @param $reply_id Optional. Used to check emptiness 310 * @return int The reply id 311 */ 312 function bbp_get_reply_id( $reply_id = 0 ) { 305 306 /** 307 * Return the id of the reply in a replies loop 308 * 309 * @since 2.0.0 bbPress (r2553) 310 * 311 * @param $reply_id Optional. Used to check emptiness 312 * @return int The reply id 313 */ 314 function bbp_get_reply_id( $reply_id = 0 ) { 313 315 $bbp = bbpress(); 314 316 $wp_query = bbp_get_wp_query(); … … 318 320 $bbp_reply_id = $reply_id; 319 321 320 // Currently inside a replies loop321 } elseif ( ! empty( $bbp->reply_query->in_the_loop ) && isset( $bbp->reply_query->post->ID ) ) {322 // Currently inside a replies loop 323 } elseif ( ! empty( $bbp->reply_query->in_the_loop ) && isset( $bbp->reply_query->post->ID ) ) { 322 324 $bbp_reply_id = $bbp->reply_query->post->ID; 323 325 324 // Currently inside a search loop325 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_reply( $bbp->search_query->post->ID ) ) {326 // Currently inside a search loop 327 } elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_reply( $bbp->search_query->post->ID ) ) { 326 328 $bbp_reply_id = $bbp->search_query->post->ID; 327 329 328 // Currently viewing a forum329 } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && ! empty( $bbp->current_reply_id ) ) {330 // Currently viewing a forum 331 } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && ! empty( $bbp->current_reply_id ) ) { 330 332 $bbp_reply_id = $bbp->current_reply_id; 331 333 332 // Currently viewing a reply333 } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) ) {334 // Currently viewing a reply 335 } elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) ) { 334 336 $bbp_reply_id = $wp_query->post->ID; 335 337 336 // Fallback337 } else {338 // Fallback 339 } else { 338 340 $bbp_reply_id = 0; 339 }341 } 340 342 341 343 // Filter & return 342 344 return (int) apply_filters( 'bbp_get_reply_id', $bbp_reply_id, $reply_id ); 343 }345 } 344 346 345 347 /** … … 397 399 echo esc_url( bbp_get_reply_permalink( $reply_id ) ); 398 400 } 399 /** 400 * Return the link to the reply 401 * 402 * @since 2.0.0 bbPress (r2553) 403 * 404 * @param int $reply_id Optional. Reply id 405 * 406 * @return string Permanent link to reply 407 */ 408 function bbp_get_reply_permalink( $reply_id = 0 ) { 401 402 /** 403 * Return the link to the reply 404 * 405 * @since 2.0.0 bbPress (r2553) 406 * 407 * @param int $reply_id Optional. Reply id 408 * 409 * @return string Permanent link to reply 410 */ 411 function bbp_get_reply_permalink( $reply_id = 0 ) { 409 412 $reply_id = bbp_get_reply_id( $reply_id ); 410 413 411 414 // Filter & return 412 415 return apply_filters( 'bbp_get_reply_permalink', get_permalink( $reply_id ), $reply_id ); 413 }416 } 414 417 415 418 /** … … 423 426 echo esc_url( bbp_get_reply_url( $reply_id ) ); 424 427 } 425 /** 426 * Return the paginated url to the reply in the reply loop 427 * 428 * @since 2.0.0 bbPress (r2679) 429 * 430 * @param int $reply_id Optional. Reply id 431 * @param string $redirect_to Optional. Pass a redirect value for use with 432 * shortcodes and other fun things. 433 * @return string Link to reply relative to paginated topic 434 */ 435 function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) { 428 429 /** 430 * Return the paginated url to the reply in the reply loop 431 * 432 * @since 2.0.0 bbPress (r2679) 433 * 434 * @param int $reply_id Optional. Reply id 435 * @param string $redirect_to Optional. Pass a redirect value for use with 436 * shortcodes and other fun things. 437 * @return string Link to reply relative to paginated topic 438 */ 439 function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) { 436 440 437 441 // Set needed variables … … 443 447 $topic_id = bbp_get_reply_topic_id( $reply_id ); 444 448 $topic = bbp_get_topic( $topic_id ); 445 } elseif ( bbp_is_topic( $reply_id ) ) {449 } elseif ( bbp_is_topic( $reply_id ) ) { 446 450 $topic_id = bbp_get_topic_id( $reply_id ); 447 451 $topic = bbp_get_topic( $topic_id ); 448 452 $reply_id = $topic_id; 449 }453 } 450 454 451 455 // Hierarchical reply page … … 453 457 $reply_page = 1; 454 458 455 // Standard reply page456 } else {459 // Standard reply page 460 } else { 457 461 $reply_page = ceil( (int) bbp_get_reply_position( $reply_id, $topic_id ) / (int) bbp_get_replies_per_page() ); 458 }462 } 459 463 460 464 // Get links & URLS … … 475 479 $url = user_trailingslashit( $topic_url ) . $reply_hash; 476 480 477 // Unpretty links478 } else {481 // Unpretty links 482 } else { 479 483 $url = $topic_url . $reply_hash; 480 }481 482 // Include pagination483 } else {484 } 485 486 // Include pagination 487 } else { 484 488 485 489 // Pretty permalinks … … 488 492 $url = user_trailingslashit( $url ) . $reply_hash; 489 493 490 // Unpretty links491 } else {494 // Unpretty links 495 } else { 492 496 $url = add_query_arg( 'paged', $reply_page, $topic_url ) . $reply_hash; 493 }494 497 } 498 } 495 499 496 500 // Add topic view query arg back to end if it is set 497 501 if ( bbp_get_view_all() ) { 498 502 $url = bbp_add_view_all( $url ); 499 }503 } 500 504 501 505 // Filter & return 502 506 return apply_filters( 'bbp_get_reply_url', $url, $reply_id, $redirect_to ); 503 }507 } 504 508 505 509 /** … … 514 518 } 515 519 516 /**517 * Return the title of the reply518 *519 * @since 2.0.0 bbPress (r2553)520 *521 * @param int $reply_id Optional. Reply id522 * @return string Title of reply523 */524 function bbp_get_reply_title( $reply_id = 0 ) {520 /** 521 * Return the title of the reply 522 * 523 * @since 2.0.0 bbPress (r2553) 524 * 525 * @param int $reply_id Optional. Reply id 526 * @return string Title of reply 527 */ 528 function bbp_get_reply_title( $reply_id = 0 ) { 525 529 $reply_id = bbp_get_reply_id( $reply_id ); 526 530 $title = get_post_field( 'post_title', $reply_id ); … … 529 533 // Filter & return 530 534 return apply_filters( 'bbp_get_reply_title', $title, $reply_id ); 531 }532 533 /**534 * Get empty reply title fallback.535 *536 * @since 2.5.0 bbPress (r5177)537 *538 * @param string $post_title Required. Reply Title539 * @param int $post_id Required. Reply ID540 * @return string Title of reply541 */542 function bbp_get_reply_title_fallback( $post_title = '', $post_id = 0 ) {535 } 536 537 /** 538 * Get empty reply title fallback. 539 * 540 * @since 2.5.0 bbPress (r5177) 541 * 542 * @param string $post_title Required. Reply Title 543 * @param int $post_id Required. Reply ID 544 * @return string Title of reply 545 */ 546 function bbp_get_reply_title_fallback( $post_title = '', $post_id = 0 ) { 543 547 544 548 // Bail if title not empty, or post is not a reply 545 549 if ( ! empty( $post_title ) || ! bbp_is_reply( $post_id ) ) { 546 550 return $post_title; 547 }551 } 548 552 549 553 // Get reply topic title. … … 551 555 552 556 // Get empty reply title fallback. 553 $reply_title = sprintf( esc_html__( 'Reply To: %s', 'bbpress' ), $topic_title ); 557 $reply_title = sprintf( 558 /* translators: %s: Topic title */ 559 esc_html__( 'Reply To: %s', 'bbpress' ), 560 $topic_title 561 ); 554 562 555 563 // Filter & return 556 564 return apply_filters( 'bbp_get_reply_title_fallback', $reply_title, $post_id, $topic_title ); 557 }565 } 558 566 559 567 /** … … 567 575 echo bbp_get_reply_content( $reply_id ); 568 576 } 569 /** 570 * Return the content of the reply 571 * 572 * @since 2.0.0 bbPress (r2780) 573 * 574 * @param int $reply_id Optional. reply id 575 * @return string Content of the reply 576 */ 577 function bbp_get_reply_content( $reply_id = 0 ) { 577 578 /** 579 * Return the content of the reply 580 * 581 * @since 2.0.0 bbPress (r2780) 582 * 583 * @param int $reply_id Optional. reply id 584 * @return string Content of the reply 585 */ 586 function bbp_get_reply_content( $reply_id = 0 ) { 578 587 $reply_id = bbp_get_reply_id( $reply_id ); 579 588 … … 581 590 if ( post_password_required( $reply_id ) ) { 582 591 return get_the_password_form(); 583 }592 } 584 593 585 594 $content = get_post_field( 'post_content', $reply_id ); … … 587 596 // Filter & return 588 597 return apply_filters( 'bbp_get_reply_content', $content, $reply_id ); 589 }598 } 590 599 591 600 /** … … 600 609 echo bbp_get_reply_excerpt( $reply_id, $length ); 601 610 } 602 /** 603 * Return the excerpt of the reply 604 * 605 * @since 2.0.0 bbPress (r2751) 606 * 607 * @param int $reply_id Optional. Reply id 608 * @param int $length Optional. Length of the excerpt. Defaults to 100 609 * letters 610 * @return string Reply Excerpt 611 */ 612 function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) { 611 612 /** 613 * Return the excerpt of the reply 614 * 615 * @since 2.0.0 bbPress (r2751) 616 * 617 * @param int $reply_id Optional. Reply id 618 * @param int $length Optional. Length of the excerpt. Defaults to 100 619 * letters 620 * @return string Reply Excerpt 621 */ 622 function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) { 613 623 $reply_id = bbp_get_reply_id( $reply_id ); 614 624 $length = (int) $length; … … 617 627 if ( empty( $excerpt ) ) { 618 628 $excerpt = bbp_get_reply_content( $reply_id ); 619 }620 621 $excerpt = trim ( strip_tags( $excerpt ) );629 } 630 631 $excerpt = trim( strip_tags( $excerpt ) ); 622 632 623 633 // Multibyte support 624 634 if ( function_exists( 'mb_strlen' ) ) { 625 635 $excerpt_length = mb_strlen( $excerpt ); 626 } else {636 } else { 627 637 $excerpt_length = strlen( $excerpt ); 628 }638 } 629 639 630 640 if ( ! empty( $length ) && ( $excerpt_length > $length ) ) { 631 641 $excerpt = mb_substr( $excerpt, 0, $length - 1 ); 632 642 $excerpt .= '…'; 633 }643 } 634 644 635 645 // Filter & return 636 646 return apply_filters( 'bbp_get_reply_excerpt', $excerpt, $reply_id, $length ); 637 }647 } 638 648 639 649 /** … … 649 659 echo bbp_get_reply_post_date( $reply_id, $humanize, $gmt ); 650 660 } 651 /** 652 * Return the post date and time of a reply 653 * 654 * @since 2.2.0 bbPress (r4155) 655 * 656 * @param int $reply_id Optional. Reply id. 657 * @param bool $humanize Optional. Humanize output using time_since 658 * @param bool $gmt Optional. Use GMT 659 * @return string 660 */ 661 function bbp_get_reply_post_date( $reply_id = 0, $humanize = false, $gmt = false ) { 661 662 /** 663 * Return the post date and time of a reply 664 * 665 * @since 2.2.0 bbPress (r4155) 666 * 667 * @param int $reply_id Optional. Reply id. 668 * @param bool $humanize Optional. Humanize output using time_since 669 * @param bool $gmt Optional. Use GMT 670 * @return string 671 */ 672 function bbp_get_reply_post_date( $reply_id = 0, $humanize = false, $gmt = false ) { 662 673 $reply_id = bbp_get_reply_id( $reply_id ); 663 674 … … 669 680 $result = bbp_get_time_since( $date ); 670 681 671 // August 4, 2012 at 2:37 pm672 } else {682 // August 4, 2012 at 2:37 pm 683 } else { 673 684 $date = get_post_time( get_option( 'date_format' ), $gmt, $reply_id, true ); 674 685 $time = get_post_time( get_option( 'time_format' ), $gmt, $reply_id, true ); 686 /* translators: 1: Date, 2: Time */ 675 687 $result = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbpress' ), $date, $time ); 676 }688 } 677 689 678 690 // Filter & return 679 691 return apply_filters( 'bbp_get_reply_post_date', $result, $reply_id, $humanize, $gmt, $date, $time ); 680 }692 } 681 693 682 694 /** … … 713 725 echo bbp_get_reply_revision_log( $reply_id ); 714 726 } 715 /** 716 * Return the formatted revision log of the reply 717 * 718 * @since 2.0.0 bbPress (r2782) 719 * 720 * @param int $reply_id Optional. Reply id 721 * @return string Revision log of the reply 722 */ 723 function bbp_get_reply_revision_log( $reply_id = 0 ) { 727 728 /** 729 * Return the formatted revision log of the reply 730 * 731 * @since 2.0.0 bbPress (r2782) 732 * 733 * @param int $reply_id Optional. Reply id 734 * @return string Revision log of the reply 735 */ 736 function bbp_get_reply_revision_log( $reply_id = 0 ) { 724 737 725 738 // Create necessary variables … … 729 742 if ( bbp_is_topic( $reply_id ) ) { 730 743 return bbp_get_topic_revision_log( $reply_id ); 731 }744 } 732 745 733 746 // Get the reply revision log (out of post meta … … 737 750 if ( empty( $reply_id ) || empty( $revision_log ) || ! is_array( $revision_log ) ) { 738 751 return false; 739 }752 } 740 753 741 754 // Get the actual revisions … … 743 756 if ( empty( $revisions ) ) { 744 757 return false; 745 }758 } 746 759 747 760 $r = "\n\n" . '<ul id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '" class="bbp-reply-revision-log">' . "\n\n"; … … 753 766 $author_id = $revision->post_author; 754 767 $reason = ''; 755 } else {768 } else { 756 769 $author_id = $revision_log[ $revision->ID ]['author']; 757 770 $reason = $revision_log[ $revision->ID ]['reason']; 758 }771 } 759 772 760 773 $author = bbp_get_author_link( array( 'size' => 14, 'link_text' => bbp_get_reply_author_display_name( $revision->ID ), 'post_id' => $revision->ID ) ); … … 763 776 $r .= "\t" . '<li id="bbp-reply-revision-log-' . esc_attr( $reply_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-reply-revision-log-item">' . "\n"; 764 777 if ( ! empty( $reason ) ) { 778 /* translators: 1: Time since modification, 2: Author linked display name, 3: Modification reason */ 765 779 $r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n"; 766 } else { 780 } else { 781 /* translators: 1: Time since modification, 2: Author linked display name */ 767 782 $r .= "\t\t" . sprintf( esc_html__( 'This reply was modified %1$s by %2$s.', 'bbpress' ), esc_html( $since ), $author ) . "\n"; 768 } 783 } 784 769 785 $r .= "\t" . '</li>' . "\n"; 770 771 } 786 } 772 787 773 788 $r .= "\n" . '</ul>' . "\n\n"; … … 775 790 // Filter & return 776 791 return apply_filters( 'bbp_get_reply_revision_log', $r, $reply_id ); 777 } 778 /** 779 * Return the raw revision log of the reply 780 * 781 * @since 2.0.0 bbPress (r2782) 782 * 783 * @param int $reply_id Optional. Reply id 784 * @return string Raw revision log of the reply 785 */ 786 function bbp_get_reply_raw_revision_log( $reply_id = 0 ) { 792 } 793 794 /** 795 * Return the raw revision log of the reply 796 * 797 * @since 2.0.0 bbPress (r2782) 798 * 799 * @param int $reply_id Optional. Reply id 800 * @return string Raw revision log of the reply 801 */ 802 function bbp_get_reply_raw_revision_log( $reply_id = 0 ) { 787 803 $reply_id = bbp_get_reply_id( $reply_id ); 788 804 $revision_log = get_post_meta( $reply_id, '_bbp_revision_log', true ); 789 805 $revision_log = ! empty( $revision_log ) 790 ? $revision_log791 : array();806 ? $revision_log 807 : array(); 792 808 793 809 // Filter & return 794 810 return apply_filters( 'bbp_get_reply_raw_revision_log', $revision_log, $reply_id ); 795 }811 } 796 812 797 813 /** … … 840 856 echo bbp_get_reply_status( $reply_id ); 841 857 } 842 /** 843 * Return the status of the reply 844 * 845 * @since 2.0.0 bbPress (r2667) 846 * 847 * @param int $reply_id Optional. Reply id 848 * @return string Status of reply 849 */ 850 function bbp_get_reply_status( $reply_id = 0 ) { 858 859 /** 860 * Return the status of the reply 861 * 862 * @since 2.0.0 bbPress (r2667) 863 * 864 * @param int $reply_id Optional. Reply id 865 * @return string Status of reply 866 */ 867 function bbp_get_reply_status( $reply_id = 0 ) { 851 868 $reply_id = bbp_get_reply_id( $reply_id ); 852 869 853 870 // Filter & return 854 871 return apply_filters( 'bbp_get_reply_status', get_post_status( $reply_id ), $reply_id ); 855 }872 } 856 873 857 874 /** … … 1002 1019 */ 1003 1020 function bbp_reply_author( $reply_id = 0 ) { 1004 echo bbp_get_reply_author( $reply_id ); 1005 } 1006 /** 1007 * Deprecated. Use bbp_get_reply_author_display_name() instead. 1008 * 1009 * Return the author of the reply 1010 * 1011 * @since 2.0.0 bbPress (r2667) 1012 * 1013 * @deprecated 2.5.0 bbPress (r5119) 1014 * 1015 * @param int $reply_id Optional. Reply id 1016 * @return string Author of reply 1017 */ 1018 function bbp_get_reply_author( $reply_id = 0 ) { 1021 echo bbp_get_reply_author_display_name( $reply_id ); 1022 } 1023 1024 /** 1025 * Deprecated. Use bbp_get_reply_author_display_name() instead. 1026 * 1027 * Return the author of the reply 1028 * 1029 * @since 2.0.0 bbPress (r2667) 1030 * 1031 * @deprecated 2.5.0 bbPress (r5119) 1032 * 1033 * @param int $reply_id Optional. Reply id 1034 * @return string Author of reply 1035 */ 1036 function bbp_get_reply_author( $reply_id = 0 ) { 1019 1037 $reply_id = bbp_get_reply_id( $reply_id ); 1020 1038 1021 1039 if ( ! bbp_is_reply_anonymous( $reply_id ) ) { 1022 1040 $author = get_the_author_meta( 'display_name', bbp_get_reply_author_id( $reply_id ) ); 1023 } else {1041 } else { 1024 1042 $author = get_post_meta( $reply_id, '_bbp_anonymous_name', true ); 1025 }1043 } 1026 1044 1027 1045 // Filter & return 1028 1046 return apply_filters( 'bbp_get_reply_author', $author, $reply_id ); 1029 }1047 } 1030 1048 1031 1049 /** … … 1039 1057 echo bbp_get_reply_author_id( $reply_id ); 1040 1058 } 1041 /** 1042 * Return the author ID of the reply 1043 * 1044 * @since 2.0.0 bbPress (r2667) 1045 * 1046 * @param int $reply_id Optional. Reply id 1047 * @return string Author id of reply 1048 */ 1049 function bbp_get_reply_author_id( $reply_id = 0 ) { 1059 1060 /** 1061 * Return the author ID of the reply 1062 * 1063 * @since 2.0.0 bbPress (r2667) 1064 * 1065 * @param int $reply_id Optional. Reply id 1066 * @return string Author id of reply 1067 */ 1068 function bbp_get_reply_author_id( $reply_id = 0 ) { 1050 1069 $reply_id = bbp_get_reply_id( $reply_id ); 1051 1070 $author_id = get_post_field( 'post_author', $reply_id ); … … 1053 1072 // Filter & return 1054 1073 return (int) apply_filters( 'bbp_get_reply_author_id', $author_id, $reply_id ); 1055 }1074 } 1056 1075 1057 1076 /** … … 1065 1084 echo bbp_get_reply_author_display_name( $reply_id ); 1066 1085 } 1067 /** 1068 * Return the author display_name of the reply 1069 * 1070 * @since 2.0.0 bbPress (r2667) 1071 * 1072 * @param int $reply_id Optional. Reply id 1073 * @return string The display name of the author of the reply 1074 */ 1075 function bbp_get_reply_author_display_name( $reply_id = 0 ) { 1086 1087 /** 1088 * Return the author display_name of the reply 1089 * 1090 * @since 2.0.0 bbPress (r2667) 1091 * 1092 * @param int $reply_id Optional. Reply id 1093 * @return string The display name of the author of the reply 1094 */ 1095 function bbp_get_reply_author_display_name( $reply_id = 0 ) { 1076 1096 $reply_id = bbp_get_reply_id( $reply_id ); 1077 1097 … … 1088 1108 if ( empty( $author_name ) ) { 1089 1109 $author_name = get_the_author_meta( 'user_login', $author_id ); 1090 }1091 1092 // User does not have an account1093 } else {1110 } 1111 1112 // User does not have an account 1113 } else { 1094 1114 $author_name = get_post_meta( $reply_id, '_bbp_anonymous_name', true ); 1095 }1115 } 1096 1116 1097 1117 // Fallback if nothing could be found 1098 1118 if ( empty( $author_name ) ) { 1099 1119 $author_name = bbp_get_fallback_display_name( $reply_id ); 1100 }1120 } 1101 1121 1102 1122 // Filter & return 1103 1123 return apply_filters( 'bbp_get_reply_author_display_name', $author_name, $reply_id ); 1104 }1124 } 1105 1125 1106 1126 /** … … 1115 1135 echo bbp_get_reply_author_avatar( $reply_id, $size ); 1116 1136 } 1117 /** 1118 * Return the author avatar of the reply 1119 * 1120 * @since 2.0.0 bbPress (r2667) 1121 * 1122 * @param int $reply_id Optional. Reply id 1123 * @param int $size Optional. Size of the avatar. Defaults to 40 1124 * @return string Avatar of author of the reply 1125 */ 1126 function bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) { 1137 1138 /** 1139 * Return the author avatar of the reply 1140 * 1141 * @since 2.0.0 bbPress (r2667) 1142 * 1143 * @param int $reply_id Optional. Reply id 1144 * @param int $size Optional. Size of the avatar. Defaults to 40 1145 * @return string Avatar of author of the reply 1146 */ 1147 function bbp_get_reply_author_avatar( $reply_id = 0, $size = 40 ) { 1127 1148 $reply_id = bbp_get_reply_id( $reply_id ); 1149 1128 1150 if ( ! empty( $reply_id ) ) { 1151 1129 1152 // Check for anonymous user 1130 1153 if ( ! bbp_is_reply_anonymous( $reply_id ) ) { 1131 1154 $author_avatar = get_avatar( bbp_get_reply_author_id( $reply_id ), $size ); 1132 } else {1155 } else { 1133 1156 $author_avatar = get_avatar( get_post_meta( $reply_id, '_bbp_anonymous_email', true ), $size ); 1134 }1135 } else {1157 } 1158 } else { 1136 1159 $author_avatar = ''; 1137 }1160 } 1138 1161 1139 1162 // Filter & return 1140 1163 return apply_filters( 'bbp_get_reply_author_avatar', $author_avatar, $reply_id, $size ); 1141 }1164 } 1142 1165 1143 1166 /** … … 1151 1174 echo bbp_get_reply_author_link( $args ); 1152 1175 } 1153 /** 1154 * Return the author link of the reply 1155 * 1156 * @since 2.0.0 bbPress (r2717) 1157 * 1158 * @param array $args Optional. If an integer, it is used as reply id. 1159 * @return string Author link of reply 1160 */ 1161 function bbp_get_reply_author_link( $args = array() ) { 1176 1177 /** 1178 * Return the author link of the reply 1179 * 1180 * @since 2.0.0 bbPress (r2717) 1181 * 1182 * @param array $args Optional. If an integer, it is used as reply id. 1183 * @return string Author link of reply 1184 */ 1185 function bbp_get_reply_author_link( $args = array() ) { 1162 1186 1163 1187 // Parse arguments against default values 1164 1188 $r = bbp_parse_args( $args, array( 1165 'post_id' => 0,1166 'link_title' => '',1167 'type' => 'both',1168 'size' => 80,1169 'sep' => '',1170 'show_role' => false1189 'post_id' => 0, 1190 'link_title' => '', 1191 'type' => 'both', 1192 'size' => 80, 1193 'sep' => '', 1194 'show_role' => false 1171 1195 ), 'get_reply_author_link' ); 1172 1196 1173 // Default return value 1174 $author_link = ''; 1175 1176 // Used as reply_id 1177 $reply_id = is_numeric( $args ) 1178 ? bbp_get_reply_id( $args ) 1179 : bbp_get_reply_id( $r['post_id'] ); 1180 1181 // Reply ID is good 1182 if ( ! empty( $reply_id ) ) { 1183 1184 // Get some useful reply information 1185 $author_url = bbp_get_reply_author_url( $reply_id ); 1186 $anonymous = bbp_is_reply_anonymous( $reply_id ); 1187 1188 // Tweak link title if empty 1189 if ( empty( $r['link_title'] ) ) { 1190 $author = bbp_get_reply_author_display_name( $reply_id ); 1191 $title = empty( $anonymous ) 1192 ? esc_attr__( "View %s's profile", 'bbpress' ) 1193 : esc_attr__( "Visit %s's website", 'bbpress' ); 1194 1195 $link_title = sprintf( $title, $author ); 1197 // Default return value 1198 $author_link = ''; 1199 1200 // Used as reply_id 1201 $reply_id = is_numeric( $args ) 1202 ? bbp_get_reply_id( $args ) 1203 : bbp_get_reply_id( $r['post_id'] ); 1204 1205 // Reply ID is good 1206 if ( ! empty( $reply_id ) ) { 1207 1208 // Get some useful reply information 1209 $author_url = bbp_get_reply_author_url( $reply_id ); 1210 $anonymous = bbp_is_reply_anonymous( $reply_id ); 1211 1212 // Tweak link title if empty 1213 if ( empty( $r['link_title'] ) ) { 1214 $author = bbp_get_reply_author_display_name( $reply_id ); 1215 $title = empty( $anonymous ) 1216 /* translators: %s: Author's display name */ 1217 ? esc_attr__( "View %s's profile", 'bbpress' ) 1218 /* translators: %s: Author's display name */ 1219 : esc_attr__( "Visit %s's website", 'bbpress' ); 1220 1221 $link_title = sprintf( $title, $author ); 1196 1222 1197 1223 // Use what was passed if not 1198 1224 } else { 1199 $link_title = $r['link_title'];1225 $link_title = $r['link_title']; 1200 1226 } 1201 1227 1202 // Setup title and author_links array1203 $author_links = array();1204 $link_title = ! empty( $link_title )1205 ? ' title="' . esc_attr( $link_title ) . '"'1206 : '';1207 1208 // Get avatar (unescaped, because HTML)1209 if ( ( 'avatar' === $r['type'] ) || ( 'both' === $r['type'] ) ) {1210 $author_links['avatar'] = bbp_get_reply_author_avatar( $reply_id, $r['size'] );1228 // Setup title and author_links array 1229 $author_links = array(); 1230 $link_title = ! empty( $link_title ) 1231 ? ' title="' . esc_attr( $link_title ) . '"' 1232 : ''; 1233 1234 // Get avatar (unescaped, because HTML) 1235 if ( ( 'avatar' === $r['type'] ) || ( 'both' === $r['type'] ) ) { 1236 $author_links['avatar'] = bbp_get_reply_author_avatar( $reply_id, $r['size'] ); 1211 1237 } 1212 1238 1213 // Get display name (escaped, because never HTML)1214 if ( ( 'name' === $r['type'] ) || ( 'both' === $r['type'] ) ) {1215 $author_links['name'] = esc_html( bbp_get_reply_author_display_name( $reply_id ) );1239 // Get display name (escaped, because never HTML) 1240 if ( ( 'name' === $r['type'] ) || ( 'both' === $r['type'] ) ) { 1241 $author_links['name'] = esc_html( bbp_get_reply_author_display_name( $reply_id ) ); 1216 1242 } 1217 1243 1218 // Empty array1219 $links = array();1220 $sprint = '<span %1$s>%2$s</span>';1221 1222 // Wrap each link1223 foreach ( $author_links as $link => $link_text ) {1224 $link_class = ' class="bbp-author-' . esc_attr( $link ) . '"';1225 $links[] = sprintf( $sprint, $link_class, $link_text );1244 // Empty array 1245 $links = array(); 1246 $sprint = '<span %1$s>%2$s</span>'; 1247 1248 // Wrap each link 1249 foreach ( $author_links as $link => $link_text ) { 1250 $link_class = ' class="bbp-author-' . esc_attr( $link ) . '"'; 1251 $links[] = sprintf( $sprint, $link_class, $link_text ); 1226 1252 } 1227 1253 1228 // Juggle1229 $author_links = $links;1230 unset( $links );1231 1232 // Filter sections1233 $sections = apply_filters( 'bbp_get_reply_author_links', $author_links, $r, $args );1234 1235 // Assemble sections into author link1236 $author_link = implode( $r['sep'], $sections );1237 1238 // Only wrap in link if profile exists1239 if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {1240 $author_link = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, ' class="bbp-author-link"', $author_link );1254 // Juggle 1255 $author_links = $links; 1256 unset( $links ); 1257 1258 // Filter sections 1259 $sections = apply_filters( 'bbp_get_reply_author_links', $author_links, $r, $args ); 1260 1261 // Assemble sections into author link 1262 $author_link = implode( $r['sep'], $sections ); 1263 1264 // Only wrap in link if profile exists 1265 if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) { 1266 $author_link = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, ' class="bbp-author-link"', $author_link ); 1241 1267 } 1242 1268 1243 // Role is not linked1244 if ( true === $r['show_role'] ) {1245 $author_link .= bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) );1269 // Role is not linked 1270 if ( true === $r['show_role'] ) { 1271 $author_link .= bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) ); 1246 1272 } 1247 1273 } 1248 1274 1249 // Filter & return1250 return apply_filters( 'bbp_get_reply_author_link', $author_link, $r, $args );1251 }1275 // Filter & return 1276 return apply_filters( 'bbp_get_reply_author_link', $author_link, $r, $args ); 1277 } 1252 1278 1253 1279 /** … … 1261 1287 echo esc_url( bbp_get_reply_author_url( $reply_id ) ); 1262 1288 } 1263 /** 1264 * Return the author url of the reply 1265 * 1266 * @since 2.0.0 bbPress (r2667) 1267 * 1268 * @param int $reply_id Optional. Reply id 1269 * @return string Author URL of the reply 1270 */ 1271 function bbp_get_reply_author_url( $reply_id = 0 ) { 1289 1290 /** 1291 * Return the author url of the reply 1292 * 1293 * @since 2.0.0 bbPress (r2667) 1294 * 1295 * @param int $reply_id Optional. Reply id 1296 * @return string Author URL of the reply 1297 */ 1298 function bbp_get_reply_author_url( $reply_id = 0 ) { 1272 1299 $reply_id = bbp_get_reply_id( $reply_id ); 1273 1300 … … 1275 1302 if ( ! bbp_is_reply_anonymous( $reply_id ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) { 1276 1303 $author_url = bbp_get_user_profile_url( bbp_get_reply_author_id( $reply_id ) ); 1277 } else {1304 } else { 1278 1305 $author_url = get_post_meta( $reply_id, '_bbp_anonymous_website', true ); 1306 1279 1307 if ( empty( $author_url ) ) { 1280 1308 $author_url = ''; 1281 }1282 1309 } 1310 } 1283 1311 1284 1312 // Filter & return 1285 1313 return apply_filters( 'bbp_get_reply_author_url', $author_url, $reply_id ); 1286 }1314 } 1287 1315 1288 1316 /** … … 1296 1324 echo bbp_get_reply_author_email( $reply_id ); 1297 1325 } 1298 /** 1299 * Return the reply author email address 1300 * 1301 * @since 2.0.0 bbPress (r3445) 1302 * 1303 * @param int $reply_id Optional. Reply id 1304 * @return string Reply author email address 1305 */ 1306 function bbp_get_reply_author_email( $reply_id = 0 ) { 1326 1327 /** 1328 * Return the reply author email address 1329 * 1330 * @since 2.0.0 bbPress (r3445) 1331 * 1332 * @param int $reply_id Optional. Reply id 1333 * @return string Reply author email address 1334 */ 1335 function bbp_get_reply_author_email( $reply_id = 0 ) { 1307 1336 $reply_id = bbp_get_reply_id( $reply_id ); 1308 1337 … … 1315 1344 $author_email = ! empty( $user->user_email ) ? $user->user_email : ''; 1316 1345 1317 // Anonymous1318 } else {1346 // Anonymous 1347 } else { 1319 1348 1320 1349 // Get email from post meta … … 1324 1353 if ( empty( $author_email ) ) { 1325 1354 $author_email = ''; 1326 }1327 1355 } 1356 } 1328 1357 1329 1358 // Filter & return 1330 1359 return apply_filters( 'bbp_get_reply_author_email', $author_email, $reply_id ); 1331 }1360 } 1332 1361 1333 1362 /** … … 1341 1370 echo bbp_get_reply_author_role( $args ); 1342 1371 } 1343 /** 1344 * Return the reply author role 1345 * 1346 * @since 2.1.0 bbPress (r3860) 1347 * 1348 * @param array $args Optional. 1349 * @return string Reply author role 1350 */ 1351 function bbp_get_reply_author_role( $args = array() ) { 1372 1373 /** 1374 * Return the reply author role 1375 * 1376 * @since 2.1.0 bbPress (r3860) 1377 * 1378 * @param array $args Optional. 1379 * @return string Reply author role 1380 */ 1381 function bbp_get_reply_author_role( $args = array() ) { 1352 1382 1353 1383 // Parse arguments against default values 1354 1384 $r = bbp_parse_args( $args, array( 1355 'reply_id' => 0,1356 'class' => false,1357 'before' => '<div class="bbp-author-role">',1358 'after' => '</div>'1385 'reply_id' => 0, 1386 'class' => false, 1387 'before' => '<div class="bbp-author-role">', 1388 'after' => '</div>' 1359 1389 ), 'get_reply_author_role' ); 1360 1390 1361 $reply_id = bbp_get_reply_id( $r['reply_id'] );1362 $role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) );1363 1364 // Backwards compatibilty with old 'class' argument1365 if ( ! empty( $r['class'] ) ) {1366 $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], esc_attr( $r['class'] ), esc_html( $role ), $r['after'] );1391 $reply_id = bbp_get_reply_id( $r['reply_id'] ); 1392 $role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ); 1393 1394 // Backwards compatibilty with old 'class' argument 1395 if ( ! empty( $r['class'] ) ) { 1396 $author_role = sprintf( '%1$s<div class="%2$s">%3$s</div>%4$s', $r['before'], esc_attr( $r['class'] ), esc_html( $role ), $r['after'] ); 1367 1397 1368 1398 // Simpler before & after arguments 1369 1399 // https://bbpress.trac.wordpress.org/ticket/2557 1370 1400 } else { 1371 $author_role = $r['before'] . $role . $r['after'];1372 } 1373 1374 // Filter & return1375 return apply_filters( 'bbp_get_reply_author_role', $author_role, $r, $args );1376 }1401 $author_role = $r['before'] . $role . $r['after']; 1402 } 1403 1404 // Filter & return 1405 return apply_filters( 'bbp_get_reply_author_role', $author_role, $r, $args ); 1406 } 1377 1407 1378 1408 /** … … 1386 1416 echo bbp_get_reply_topic_title( $reply_id ); 1387 1417 } 1388 /** 1389 * Return the topic title a reply belongs to 1390 * 1391 * @since 2.0.0 bbPress (r2553) 1392 * 1393 * @param int $reply_id Optional. Reply id 1394 * @return string The topic title of the reply 1395 */ 1396 function bbp_get_reply_topic_title( $reply_id = 0 ) { 1418 1419 /** 1420 * Return the topic title a reply belongs to 1421 * 1422 * @since 2.0.0 bbPress (r2553) 1423 * 1424 * @param int $reply_id Optional. Reply id 1425 * @return string The topic title of the reply 1426 */ 1427 function bbp_get_reply_topic_title( $reply_id = 0 ) { 1397 1428 $reply_id = bbp_get_reply_id( $reply_id ); 1398 1429 $topic_id = bbp_get_reply_topic_id( $reply_id ); … … 1401 1432 // Filter & return 1402 1433 return apply_filters( 'bbp_get_reply_topic_title', $title, $reply_id ); 1403 }1434 } 1404 1435 1405 1436 /** … … 1413 1444 echo bbp_get_reply_topic_id( $reply_id ); 1414 1445 } 1415 /** 1416 * Return the topic id a reply belongs to 1417 * 1418 * @since 2.0.0 bbPress (r2553) 1419 * 1420 * @param int $reply_id Optional. Reply id 1421 * @return int The topic id of the reply 1422 */ 1423 function bbp_get_reply_topic_id( $reply_id = 0 ) { 1446 1447 /** 1448 * Return the topic id a reply belongs to 1449 * 1450 * @since 2.0.0 bbPress (r2553) 1451 * 1452 * @param int $reply_id Optional. Reply id 1453 * @return int The topic id of the reply 1454 */ 1455 function bbp_get_reply_topic_id( $reply_id = 0 ) { 1424 1456 $reply_id = bbp_get_reply_id( $reply_id ); 1425 1457 $topic_id = (int) get_post_field( 'post_parent', $reply_id ); … … 1428 1460 if ( empty( $topic_id ) ) { 1429 1461 $topic_id = (int) get_post_meta( $reply_id, '_bbp_topic_id', true ); 1430 }1462 } 1431 1463 1432 1464 // Filter 1433 1465 if ( ! empty( $topic_id ) ) { 1434 1466 $topic_id = (int) bbp_get_topic_id( $topic_id ); 1435 }1467 } 1436 1468 1437 1469 // Filter & return 1438 1470 return (int) apply_filters( 'bbp_get_reply_topic_id', $topic_id, $reply_id ); 1439 }1471 } 1440 1472 1441 1473 /** … … 1449 1481 echo bbp_get_reply_forum_id( $reply_id ); 1450 1482 } 1451 /** 1452 * Return the forum id a reply belongs to 1453 * 1454 * @since 2.0.0 bbPress (r2679) 1455 * 1456 * @param int $reply_id Optional. Reply id 1457 * 1458 * @return int The forum id of the reply 1459 */ 1460 function bbp_get_reply_forum_id( $reply_id = 0 ) { 1483 1484 /** 1485 * Return the forum id a reply belongs to 1486 * 1487 * @since 2.0.0 bbPress (r2679) 1488 * 1489 * @param int $reply_id Optional. Reply id 1490 * 1491 * @return int The forum id of the reply 1492 */ 1493 function bbp_get_reply_forum_id( $reply_id = 0 ) { 1461 1494 $reply_id = bbp_get_reply_id( $reply_id ); 1462 1495 $topic_id = bbp_get_reply_topic_id( $reply_id ); … … 1466 1499 if ( empty( $forum_id ) ) { 1467 1500 $forum_id = (int) get_post_meta( $reply_id, '_bbp_forum_id', true ); 1468 }1501 } 1469 1502 1470 1503 // Filter 1471 1504 if ( ! empty( $forum_id ) ) { 1472 1505 $forum_id = (int) bbp_get_forum_id( $forum_id ); 1473 }1506 } 1474 1507 1475 1508 // Filter & return 1476 1509 return (int) apply_filters( 'bbp_get_reply_forum_id', $forum_id, $reply_id ); 1477 }1510 } 1478 1511 1479 1512 /** … … 1487 1520 echo bbp_get_reply_ancestor_id( $reply_id ); 1488 1521 } 1489 /** 1490 * Return the ancestor reply id of a reply 1491 * 1492 * @since 2.4.0 bbPress (r4944) 1493 * 1494 * @param in $reply_id Reply id 1495 */ 1496 function bbp_get_reply_ancestor_id( $reply_id = 0 ) { 1522 1523 /** 1524 * Return the ancestor reply id of a reply 1525 * 1526 * @since 2.4.0 bbPress (r4944) 1527 * 1528 * @param in $reply_id Reply id 1529 */ 1530 function bbp_get_reply_ancestor_id( $reply_id = 0 ) { 1497 1531 1498 1532 // Validation … … 1500 1534 if ( empty( $reply_id ) ) { 1501 1535 return false; 1502 }1536 } 1503 1537 1504 1538 // Find highest reply ancestor … … 1507 1541 if ( empty( $parent_id ) || ( $parent_id === $ancestor_id ) || ( bbp_get_reply_topic_id( $reply_id ) === $parent_id ) || ( $parent_id === $reply_id ) ) { 1508 1542 break; 1509 } 1543 } 1544 1510 1545 $ancestor_id = $parent_id; 1511 }1546 } 1512 1547 1513 1548 return (int) $ancestor_id; 1514 }1549 } 1515 1550 1516 1551 /** … … 1524 1559 echo bbp_get_reply_to( $reply_id ); 1525 1560 } 1526 /** 1527 * Return the reply to id of a reply 1528 * 1529 * @since 2.4.0 bbPress (r4944) 1530 * 1531 * @param int $reply_id Optional. Reply id 1532 * @return int The parent reply id of the reply 1533 */ 1534 function bbp_get_reply_to( $reply_id = 0 ) { 1561 1562 /** 1563 * Return the reply to id of a reply 1564 * 1565 * @since 2.4.0 bbPress (r4944) 1566 * 1567 * @param int $reply_id Optional. Reply id 1568 * @return int The parent reply id of the reply 1569 */ 1570 function bbp_get_reply_to( $reply_id = 0 ) { 1535 1571 1536 1572 // Assume there is no reply_to set … … 1543 1579 if ( ! empty( $reply_id ) ) { 1544 1580 $reply_to = (int) get_post_meta( $reply_id, '_bbp_reply_to', true ); 1545 }1581 } 1546 1582 1547 1583 // Filter & return 1548 1584 return (int) apply_filters( 'bbp_get_reply_to', $reply_to, $reply_id ); 1549 }1585 } 1550 1586 1551 1587 /** … … 1560 1596 } 1561 1597 1562 /**1563 * Return the link for a reply to a reply1564 *1565 * @since 2.4.0 bbPress (r4944)1566 *1567 * @param array $args Arguments1568 * @return string Link for a reply to a reply1569 */1570 function bbp_get_reply_to_link( $args = array() ) {1598 /** 1599 * Return the link for a reply to a reply 1600 * 1601 * @since 2.4.0 bbPress (r4944) 1602 * 1603 * @param array $args Arguments 1604 * @return string Link for a reply to a reply 1605 */ 1606 function bbp_get_reply_to_link( $args = array() ) { 1571 1607 1572 1608 // Parse arguments against default values 1573 1609 $r = bbp_parse_args( $args, array( 1574 'id'=> 0,1575 'link_before'=> '',1576 'link_after'=> '',1577 'reply_text'=> esc_html_x( 'Reply', 'verb', 'bbpress' ),1578 'depth'=> 0,1579 'add_below'=> 'post',1580 'respond_id'=> 'new-reply-' . bbp_get_topic_id(),1610 'id' => 0, 1611 'link_before' => '', 1612 'link_after' => '', 1613 'reply_text' => esc_html_x( 'Reply', 'verb', 'bbpress' ), 1614 'depth' => 0, 1615 'add_below' => 'post', 1616 'respond_id' => 'new-reply-' . bbp_get_topic_id(), 1581 1617 ), 'get_reply_to_link' ); 1582 1618 1583 // Get the reply to use it's ID and post_parent1584 $reply = bbp_get_reply( $r['id'] );1585 $topic_id = bbp_get_reply_topic_id( $reply->ID );1586 1587 // Bail if no reply or user cannot reply1588 if ( empty( $reply ) || empty( $topic_id ) || bbp_is_single_reply() || ! bbp_current_user_can_access_create_reply_form() ) {1589 return;1590 } 1591 1592 // Build the URI and return value1593 $uri = bbp_get_reply_url( $reply->ID );1594 $uri = strtok( $uri, '#' );1595 $uri = add_query_arg( array( 'bbp_reply_to' => $reply->ID ), $uri );1596 $uri = wp_nonce_url( $uri, 'respond_id_' . $reply->ID );1597 $uri = $uri . '#new-post';1598 1599 // Only add onclick if replies are threaded1600 if ( bbp_thread_replies() ) {1601 1602 // Array of classes to pass to moveForm1603 $move_form = array(1604 $r['add_below'] . '-' . $reply->ID,1605 $reply->ID,1606 $r['respond_id'],1607 $reply->post_parent1608 );1609 1610 // Build the onclick1611 $onclick= ' onclick="return addReply.moveForm(\'' . implode( "','", $move_form ) . '\');"';1619 // Get the reply to use it's ID and post_parent 1620 $reply = bbp_get_reply( $r['id'] ); 1621 $topic_id = bbp_get_reply_topic_id( $reply->ID ); 1622 1623 // Bail if no reply or user cannot reply 1624 if ( empty( $reply ) || empty( $topic_id ) || bbp_is_single_reply() || ! bbp_current_user_can_access_create_reply_form() ) { 1625 return; 1626 } 1627 1628 // Build the URI and return value 1629 $uri = bbp_get_reply_url( $reply->ID ); 1630 $uri = strtok( $uri, '#' ); 1631 $uri = add_query_arg( array( 'bbp_reply_to' => $reply->ID ), $uri ); 1632 $uri = wp_nonce_url( $uri, 'respond_id_' . $reply->ID ); 1633 $uri = $uri . '#new-post'; 1634 1635 // Only add onclick if replies are threaded 1636 if ( bbp_thread_replies() ) { 1637 1638 // Array of classes to pass to moveForm 1639 $move_form = array( 1640 $r['add_below'] . '-' . $reply->ID, 1641 $reply->ID, 1642 $r['respond_id'], 1643 $reply->post_parent 1644 ); 1645 1646 // Build the onclick 1647 $onclick = ' onclick="return addReply.moveForm(\'' . implode( "','", $move_form ) . '\');"'; 1612 1648 1613 1649 // No onclick if replies are not threaded 1614 1650 } else { 1615 $onclick= '';1616 } 1617 1618 // Add $uri to the array, to be passed through the filter1619 $r['uri'] = $uri;1620 $retval = $r['link_before'] . '<a role="button" href="' . esc_url( $r['uri'] ) . '" class="bbp-reply-to-link"' . $onclick . '>' . $r['reply_text'] . '</a>' . $r['link_after'];1621 1622 // Filter & return1623 return apply_filters( 'bbp_get_reply_to_link', $retval, $r, $args );1624 }1651 $onclick = ''; 1652 } 1653 1654 // Add $uri to the array, to be passed through the filter 1655 $r['uri'] = $uri; 1656 $retval = $r['link_before'] . '<a role="button" href="' . esc_url( $r['uri'] ) . '" class="bbp-reply-to-link"' . $onclick . '>' . $r['reply_text'] . '</a>' . $r['link_after']; 1657 1658 // Filter & return 1659 return apply_filters( 'bbp_get_reply_to_link', $retval, $r, $args ); 1660 } 1625 1661 1626 1662 /** … … 1632 1668 echo bbp_get_cancel_reply_to_link( $text ); 1633 1669 } 1634 /** 1635 * Return the cancellation link for a reply to a reply 1636 * 1637 * @since 2.4.0 bbPress (r4944) 1638 * 1639 * @param string $text The cancel text 1640 * @return string The cancellation link 1641 */ 1642 function bbp_get_cancel_reply_to_link( $text = '' ) { 1670 1671 /** 1672 * Return the cancellation link for a reply to a reply 1673 * 1674 * @since 2.4.0 bbPress (r4944) 1675 * 1676 * @param string $text The cancel text 1677 * @return string The cancellation link 1678 */ 1679 function bbp_get_cancel_reply_to_link( $text = '' ) { 1643 1680 1644 1681 // Bail if not hierarchical or editing a reply 1645 1682 if ( ! bbp_thread_replies() || bbp_is_reply_edit() ) { 1646 1683 return; 1647 }1684 } 1648 1685 1649 1686 // Set default text 1650 1687 if ( empty( $text ) ) { 1651 1688 $text = esc_html__( 'Cancel', 'bbpress' ); 1652 }1689 } 1653 1690 1654 1691 // Replying to... 1655 1692 $reply_to = isset( $_GET['bbp_reply_to'] ) 1656 ? (int) $_GET['bbp_reply_to']1657 : 0;1693 ? (int) $_GET['bbp_reply_to'] 1694 : 0; 1658 1695 1659 1696 // Set visibility … … 1664 1701 // Filter & return 1665 1702 return apply_filters( 'bbp_get_cancel_reply_to_link', $retval, $link, $text ); 1666 }1703 } 1667 1704 1668 1705 /** … … 1677 1714 echo bbp_get_reply_position( $reply_id, $topic_id ); 1678 1715 } 1679 /** 1680 * Return the numeric position of a reply within a topic 1681 * 1682 * @since 2.0.0 bbPress (r2984) 1683 * 1684 * @param int $reply_id Optional. Reply id 1685 * @param int $topic_id Optional. Topic id 1686 * @return int Reply position 1687 */ 1688 function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) { 1716 1717 /** 1718 * Return the numeric position of a reply within a topic 1719 * 1720 * @since 2.0.0 bbPress (r2984) 1721 * 1722 * @param int $reply_id Optional. Reply id 1723 * @param int $topic_id Optional. Topic id 1724 * @return int Reply position 1725 */ 1726 function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) { 1689 1727 1690 1728 // Get required data … … 1708 1746 if ( ! empty( $reply_position ) ) { 1709 1747 bbp_update_reply_position( $reply_id, $reply_position ); 1710 }1748 } 1711 1749 1712 1750 // Topic's position is always 0 1713 1751 } else { 1714 $reply_position = 0;1752 $reply_position = 0; 1715 1753 } 1716 1754 } … … 1719 1757 if ( ! bbp_show_lead_topic() ) { 1720 1758 $reply_position++; 1721 }1759 } 1722 1760 1723 1761 // Filter & return 1724 1762 return (int) apply_filters( 'bbp_get_reply_position', $reply_position, $reply_id, $topic_id ); 1725 }1763 } 1726 1764 1727 1765 /** Reply Admin Links *********************************************************/ … … 1737 1775 echo bbp_get_reply_admin_links( $args ); 1738 1776 } 1739 /** 1740 * Return admin links for reply 1741 * 1742 * @since 2.0.0 bbPress (r2667) 1743 * 1744 * @param array $args This function supports these arguments: 1745 * - id: Optional. Reply id 1746 * - before: HTML before the links. Defaults to 1747 * '<span class="bbp-admin-links">' 1748 * - after: HTML after the links. Defaults to '</span>' 1749 * - sep: Separator. Defaults to ' | ' 1750 * - links: Array of the links to display. By default, edit, trash, 1751 * spam, reply move, and topic split links are displayed 1752 * @return string Reply admin links 1753 */ 1754 function bbp_get_reply_admin_links( $args = array() ) { 1777 1778 /** 1779 * Return admin links for reply 1780 * 1781 * @since 2.0.0 bbPress (r2667) 1782 * 1783 * @param array $args This function supports these arguments: 1784 * - id: Optional. Reply id 1785 * - before: HTML before the links. Defaults to 1786 * '<span class="bbp-admin-links">' 1787 * - after: HTML after the links. Defaults to '</span>' 1788 * - sep: Separator. Defaults to ' | ' 1789 * - links: Array of the links to display. By default, edit, trash, 1790 * spam, reply move, and topic split links are displayed 1791 * @return string Reply admin links 1792 */ 1793 function bbp_get_reply_admin_links( $args = array() ) { 1755 1794 1756 1795 // Parse arguments against default values 1757 1796 $r = bbp_parse_args( $args, array( 1758 'id' => 0,1759 'before' => '<span class="bbp-admin-links">',1760 'after' => '</span>',1761 'sep' => ' | ',1762 'links' => array()1797 'id' => 0, 1798 'before' => '<span class="bbp-admin-links">', 1799 'after' => '</span>', 1800 'sep' => ' | ', 1801 'links' => array() 1763 1802 ), 'get_reply_admin_links' ); 1764 1803 1765 $r['id'] = bbp_get_reply_id( $r['id'] );1766 1767 // If post is a topic, return the topic admin links instead1768 if ( bbp_is_topic( $r['id'] ) ) {1769 return bbp_get_topic_admin_links( $args );1770 } 1771 1772 // If post is not a reply, return1773 if ( ! bbp_is_reply( $r['id'] ) ) {1774 return;1775 } 1776 1777 // If topic is trashed, do not show admin links1778 if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) ) {1779 return;1780 } 1781 1782 // If no links were passed, default to the standard1783 if ( empty( $r['links'] ) ) {1784 $r['links'] = apply_filters( 'bbp_reply_admin_links', array(1785 'edit' => bbp_get_reply_edit_link ( $r ),1786 'move' => bbp_get_reply_move_link ( $r ),1787 'split' => bbp_get_topic_split_link ( $r ),1788 'trash' => bbp_get_reply_trash_link ( $r ),1789 'spam' => bbp_get_reply_spam_link ( $r ),1790 'approve' => bbp_get_reply_approve_link( $r ),1791 'reply' => bbp_get_reply_to_link ( $r )1792 ), $r['id'] );1793 }1794 1795 // See if links need to be unset1796 $reply_status = bbp_get_reply_status( $r['id'] );1797 if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ), true ) ) {1798 1799 // Spam link shouldn't be visible on trashed topics1800 if ( bbp_get_trash_status_id() === $reply_status ) {1801 unset( $r['links']['spam'] );1804 $r['id'] = bbp_get_reply_id( $r['id'] ); 1805 1806 // If post is a topic, return the topic admin links instead 1807 if ( bbp_is_topic( $r['id'] ) ) { 1808 return bbp_get_topic_admin_links( $args ); 1809 } 1810 1811 // If post is not a reply, return 1812 if ( ! bbp_is_reply( $r['id'] ) ) { 1813 return; 1814 } 1815 1816 // If topic is trashed, do not show admin links 1817 if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) ) { 1818 return; 1819 } 1820 1821 // If no links were passed, default to the standard 1822 if ( empty( $r['links'] ) ) { 1823 $r['links'] = apply_filters( 'bbp_reply_admin_links', array( 1824 'edit' => bbp_get_reply_edit_link ( $r ), 1825 'move' => bbp_get_reply_move_link ( $r ), 1826 'split' => bbp_get_topic_split_link ( $r ), 1827 'trash' => bbp_get_reply_trash_link ( $r ), 1828 'spam' => bbp_get_reply_spam_link ( $r ), 1829 'approve' => bbp_get_reply_approve_link( $r ), 1830 'reply' => bbp_get_reply_to_link ( $r ) 1831 ), $r['id'] ); 1832 } 1833 1834 // See if links need to be unset 1835 $reply_status = bbp_get_reply_status( $r['id'] ); 1836 if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ), true ) ) { 1837 1838 // Spam link shouldn't be visible on trashed topics 1839 if ( bbp_get_trash_status_id() === $reply_status ) { 1840 unset( $r['links']['spam'] ); 1802 1841 1803 1842 // Trash link shouldn't be visible on spam topics 1804 1843 } elseif ( bbp_get_spam_status_id() === $reply_status ) { 1805 unset( $r['links']['trash'] );1844 unset( $r['links']['trash'] ); 1806 1845 } 1807 1846 } 1808 1847 1809 // Process the admin links1810 $links = implode( $r['sep'], array_filter( $r['links'] ) );1811 $retval = $r['before'] . $links . $r['after'];1812 1813 // Filter & return1814 return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args );1815 }1848 // Process the admin links 1849 $links = implode( $r['sep'], array_filter( $r['links'] ) ); 1850 $retval = $r['before'] . $links . $r['after']; 1851 1852 // Filter & return 1853 return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args ); 1854 } 1816 1855 1817 1856 /** … … 1826 1865 } 1827 1866 1828 /**1829 * Return the edit link of the reply1830 *1831 * @since 2.0.0 bbPress (r2740)1832 *1833 * @param array $args This function supports these arguments:1834 * - id: Reply id1835 * - link_before: HTML before the link1836 * - link_after: HTML after the link1837 * - edit_text: Edit text. Defaults to 'Edit'1838 * @return string Reply edit link1839 */1840 function bbp_get_reply_edit_link( $args = array() ) {1867 /** 1868 * Return the edit link of the reply 1869 * 1870 * @since 2.0.0 bbPress (r2740) 1871 * 1872 * @param array $args This function supports these arguments: 1873 * - id: Reply id 1874 * - link_before: HTML before the link 1875 * - link_after: HTML after the link 1876 * - edit_text: Edit text. Defaults to 'Edit' 1877 * @return string Reply edit link 1878 */ 1879 function bbp_get_reply_edit_link( $args = array() ) { 1841 1880 1842 1881 // Parse arguments against default values 1843 1882 $r = bbp_parse_args( $args, array( 1844 'id' => 0,1845 'link_before' => '',1846 'link_after' => '',1847 'edit_text' => esc_html__( 'Edit', 'bbpress' )1883 'id' => 0, 1884 'link_before' => '', 1885 'link_after' => '', 1886 'edit_text' => esc_html__( 'Edit', 'bbpress' ) 1848 1887 ), 'get_reply_edit_link' ); 1849 1888 1850 // Get reply 1851 $reply = bbp_get_reply( $r['id'] ); 1852 1853 // Bypass check if user has caps 1854 if ( ! current_user_can( 'edit_others_replies' ) ) { 1855 1856 // User cannot edit or it is past the lock time 1857 if ( empty( $reply ) || ! current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) ) { 1889 // Get reply 1890 $reply = bbp_get_reply( $r['id'] ); 1891 1892 // Bypass check if user has caps 1893 if ( ! current_user_can( 'edit_others_replies' ) ) { 1894 1895 // User cannot edit or it is past the lock time 1896 if ( empty( $reply ) || ! current_user_can( 'edit_reply', $reply->ID ) || bbp_past_edit_lock( $reply->post_date_gmt ) ) { 1897 return; 1898 } 1899 } 1900 1901 // Get uri 1902 $uri = bbp_get_reply_edit_url( $r['id'] ); 1903 1904 // Bail if no uri 1905 if ( empty( $uri ) ) { 1858 1906 return; 1859 } 1860 } 1861 1862 // Get uri 1863 $uri = bbp_get_reply_edit_url( $r['id'] ); 1864 1865 // Bail if no uri 1866 if ( empty( $uri ) ) { 1867 return; 1868 } 1869 1870 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-edit-link">' . $r['edit_text'] . '</a>' . $r['link_after']; 1871 1872 // Filter & return 1873 return apply_filters( 'bbp_get_reply_edit_link', $retval, $r, $args ); 1874 } 1907 } 1908 1909 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-edit-link">' . $r['edit_text'] . '</a>' . $r['link_after']; 1910 1911 // Filter & return 1912 return apply_filters( 'bbp_get_reply_edit_link', $retval, $r, $args ); 1913 } 1875 1914 1876 1915 /** … … 1884 1923 echo esc_url( bbp_get_reply_edit_url( $reply_id ) ); 1885 1924 } 1886 /** 1887 * Return URL to the reply edit page 1888 * 1889 * @since 2.0.0 bbPress (r2753) 1890 * 1891 * @param int $reply_id Optional. Reply id 1892 * @return string Reply edit url 1893 */ 1894 function bbp_get_reply_edit_url( $reply_id = 0 ) { 1925 1926 /** 1927 * Return URL to the reply edit page 1928 * 1929 * @since 2.0.0 bbPress (r2753) 1930 * 1931 * @param int $reply_id Optional. Reply id 1932 * @return string Reply edit url 1933 */ 1934 function bbp_get_reply_edit_url( $reply_id = 0 ) { 1895 1935 1896 1936 // Bail if no reply … … 1898 1938 if ( empty( $reply ) ) { 1899 1939 return; 1900 }1940 } 1901 1941 1902 1942 $reply_link = bbp_remove_view_all( bbp_get_reply_permalink( $reply_id ) ); … … 1908 1948 $url = user_trailingslashit( $url ); 1909 1949 1910 // Unpretty permalinks1911 } else {1950 // Unpretty permalinks 1951 } else { 1912 1952 $url = add_query_arg( array( 1913 bbp_get_reply_post_type() => $reply->post_name,1914 bbp_get_edit_rewrite_id() => '1'1953 bbp_get_reply_post_type() => $reply->post_name, 1954 bbp_get_edit_rewrite_id() => '1' 1915 1955 ), $reply_link ); 1916 }1956 } 1917 1957 1918 1958 // Maybe add view all … … 1921 1961 // Filter & return 1922 1962 return apply_filters( 'bbp_get_reply_edit_url', $url, $reply_id ); 1923 }1963 } 1924 1964 1925 1965 /** … … 1934 1974 } 1935 1975 1936 /**1937 * Return the trash link of the reply1938 *1939 * @since 2.0.0 bbPress (r2740)1940 *1941 * @param array $args This function supports these arguments:1942 * - id: Reply id1943 * - link_before: HTML before the link1944 * - link_after: HTML after the link1945 * - sep: Separator1946 * - trash_text: Trash text1947 * - restore_text: Restore text1948 * - delete_text: Delete text1949 * @return string Reply trash link1950 */1951 function bbp_get_reply_trash_link( $args = array() ) {1976 /** 1977 * Return the trash link of the reply 1978 * 1979 * @since 2.0.0 bbPress (r2740) 1980 * 1981 * @param array $args This function supports these arguments: 1982 * - id: Reply id 1983 * - link_before: HTML before the link 1984 * - link_after: HTML after the link 1985 * - sep: Separator 1986 * - trash_text: Trash text 1987 * - restore_text: Restore text 1988 * - delete_text: Delete text 1989 * @return string Reply trash link 1990 */ 1991 function bbp_get_reply_trash_link( $args = array() ) { 1952 1992 1953 1993 // Parse arguments against default values 1954 1994 $r = bbp_parse_args( $args, array( 1955 'id' => 0,1956 'link_before' => '',1957 'link_after' => '',1958 'sep' => ' | ',1959 'trash_text' => esc_html__( 'Trash', 'bbpress' ),1960 'restore_text' => esc_html__( 'Restore', 'bbpress' ),1961 'delete_text' => esc_html__( 'Delete', 'bbpress' )1995 'id' => 0, 1996 'link_before' => '', 1997 'link_after' => '', 1998 'sep' => ' | ', 1999 'trash_text' => esc_html__( 'Trash', 'bbpress' ), 2000 'restore_text' => esc_html__( 'Restore', 'bbpress' ), 2001 'delete_text' => esc_html__( 'Delete', 'bbpress' ) 1962 2002 ), 'get_reply_trash_link' ); 1963 2003 1964 // Get reply1965 $reply = bbp_get_reply( $r['id'] );1966 1967 // Bail if no reply or current user cannot delete1968 if ( empty( $reply ) || ! current_user_can( 'delete_reply', $reply->ID ) ) {1969 return;1970 } 1971 1972 $actions = array();1973 $trash_days = bbp_get_trash_days( bbp_get_reply_post_type() );1974 1975 // Trashed1976 if ( bbp_is_reply_trash( $reply->ID ) ) {1977 $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'untrash', 'reply_id' => $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-restore-link">' . $r['restore_text'] . '</a>';2004 // Get reply 2005 $reply = bbp_get_reply( $r['id'] ); 2006 2007 // Bail if no reply or current user cannot delete 2008 if ( empty( $reply ) || ! current_user_can( 'delete_reply', $reply->ID ) ) { 2009 return; 2010 } 2011 2012 $actions = array(); 2013 $trash_days = bbp_get_trash_days( bbp_get_reply_post_type() ); 2014 2015 // Trashed 2016 if ( bbp_is_reply_trash( $reply->ID ) ) { 2017 $actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'untrash', 'reply_id' => $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-restore-link">' . $r['restore_text'] . '</a>'; 1978 2018 1979 2019 // Trash 1980 2020 } elseif ( ! empty( $trash_days ) ) { 1981 $actions['trash'] = '<a title="' . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'trash', 'reply_id' => $reply->ID ) ), 'trash-' . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-trash-link">' . $r['trash_text'] . '</a>';1982 } 1983 1984 // No trash1985 if ( bbp_is_reply_trash( $reply->ID ) || empty( $trash_days ) ) {1986 $actions['delete'] = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'delete', 'reply_id' => $reply->ID ) ), 'delete-' . $reply->post_type . '_' . $reply->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-reply-delete-link">' . $r['delete_text'] . '</a>';1987 } 1988 1989 // Process the admin links1990 $retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after'];1991 1992 // Filter & return1993 return apply_filters( 'bbp_get_reply_trash_link', $retval, $r, $args );1994 }2021 $actions['trash'] = '<a title="' . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'trash', 'reply_id' => $reply->ID ) ), 'trash-' . $reply->post_type . '_' . $reply->ID ) ) . '" class="bbp-reply-trash-link">' . $r['trash_text'] . '</a>'; 2022 } 2023 2024 // No trash 2025 if ( bbp_is_reply_trash( $reply->ID ) || empty( $trash_days ) ) { 2026 $actions['delete'] = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_reply_trash', 'sub_action' => 'delete', 'reply_id' => $reply->ID ) ), 'delete-' . $reply->post_type . '_' . $reply->ID ) ) . '" onclick="return confirm(\'' . esc_js( __( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-reply-delete-link">' . $r['delete_text'] . '</a>'; 2027 } 2028 2029 // Process the admin links 2030 $retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after']; 2031 2032 // Filter & return 2033 return apply_filters( 'bbp_get_reply_trash_link', $retval, $r, $args ); 2034 } 1995 2035 1996 2036 /** … … 2005 2045 } 2006 2046 2007 /**2008 * Return the spam link of the reply2009 *2010 * @since 2.0.0 bbPress (r2740)2011 *2012 * @param array $args This function supports these arguments:2013 * - id: Reply id2014 * - link_before: HTML before the link2015 * - link_after: HTML after the link2016 * - spam_text: Spam text2017 * - unspam_text: Unspam text2018 * @return string Reply spam link2019 */2020 function bbp_get_reply_spam_link( $args = array() ) {2047 /** 2048 * Return the spam link of the reply 2049 * 2050 * @since 2.0.0 bbPress (r2740) 2051 * 2052 * @param array $args This function supports these arguments: 2053 * - id: Reply id 2054 * - link_before: HTML before the link 2055 * - link_after: HTML after the link 2056 * - spam_text: Spam text 2057 * - unspam_text: Unspam text 2058 * @return string Reply spam link 2059 */ 2060 function bbp_get_reply_spam_link( $args = array() ) { 2021 2061 2022 2062 // Parse arguments against default values 2023 2063 $r = bbp_parse_args( $args, array( 2024 'id' => 0,2025 'link_before' => '',2026 'link_after' => '',2027 'spam_text' => esc_html__( 'Spam', 'bbpress' ),2028 'unspam_text' => esc_html__( 'Unspam', 'bbpress' )2064 'id' => 0, 2065 'link_before' => '', 2066 'link_after' => '', 2067 'spam_text' => esc_html__( 'Spam', 'bbpress' ), 2068 'unspam_text' => esc_html__( 'Unspam', 'bbpress' ) 2029 2069 ), 'get_reply_spam_link' ); 2030 2070 2031 // Get reply2032 $reply = bbp_get_reply( $r['id'] );2033 2034 // Bail if no reply or current user cannot moderate2035 if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {2036 return;2037 } 2038 2039 $display = bbp_is_reply_spam( $reply->ID ) ? $r['unspam_text'] : $r['spam_text'];2040 $uri = add_query_arg( array( 'action' => 'bbp_toggle_reply_spam', 'reply_id' => $reply->ID ) );2041 $uri = wp_nonce_url( $uri, 'spam-reply_' . $reply->ID );2042 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-spam-link">' . $display . '</a>' . $r['link_after'];2043 2044 // Filter & return2045 return apply_filters( 'bbp_get_reply_spam_link', $retval, $r, $args );2046 }2071 // Get reply 2072 $reply = bbp_get_reply( $r['id'] ); 2073 2074 // Bail if no reply or current user cannot moderate 2075 if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) { 2076 return; 2077 } 2078 2079 $display = bbp_is_reply_spam( $reply->ID ) ? $r['unspam_text'] : $r['spam_text']; 2080 $uri = add_query_arg( array( 'action' => 'bbp_toggle_reply_spam', 'reply_id' => $reply->ID ) ); 2081 $uri = wp_nonce_url( $uri, 'spam-reply_' . $reply->ID ); 2082 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-spam-link">' . $display . '</a>' . $r['link_after']; 2083 2084 // Filter & return 2085 return apply_filters( 'bbp_get_reply_spam_link', $retval, $r, $args ); 2086 } 2047 2087 2048 2088 /** … … 2059 2099 } 2060 2100 2061 /**2062 * Get move reply link2063 *2064 * Return the move link of the reply2065 *2066 * @since 2.3.0 bbPress (r4521)2067 *2068 * @param array $args This function supports these arguments:2069 * - id: Reply id2070 * - link_before: HTML before the link2071 * - link_after: HTML after the link2072 * - move_text: Move text2073 * - move_title: Move title attribute2074 * @return string Reply move link2075 */2076 function bbp_get_reply_move_link( $args = array() ) {2101 /** 2102 * Get move reply link 2103 * 2104 * Return the move link of the reply 2105 * 2106 * @since 2.3.0 bbPress (r4521) 2107 * 2108 * @param array $args This function supports these arguments: 2109 * - id: Reply id 2110 * - link_before: HTML before the link 2111 * - link_after: HTML after the link 2112 * - move_text: Move text 2113 * - move_title: Move title attribute 2114 * @return string Reply move link 2115 */ 2116 function bbp_get_reply_move_link( $args = array() ) { 2077 2117 2078 2118 // Parse arguments against default values 2079 2119 $r = bbp_parse_args( $args, array( 2080 'id' => 0,2081 'link_before' => '',2082 'link_after' => '',2083 'split_text' => esc_html__( 'Move', 'bbpress' ),2084 'split_title' => esc_attr__( 'Move this reply', 'bbpress' )2120 'id' => 0, 2121 'link_before' => '', 2122 'link_after' => '', 2123 'split_text' => esc_html__( 'Move', 'bbpress' ), 2124 'split_title' => esc_attr__( 'Move this reply', 'bbpress' ) 2085 2125 ), 'get_reply_move_link' ); 2086 2126 2087 // Get IDs2088 $reply_id = bbp_get_reply_id( $r['id'] );2089 $topic_id = bbp_get_reply_topic_id( $reply_id );2090 2091 // Bail if no reply ID or user cannot moderate2092 if ( empty( $reply_id ) || ! current_user_can( 'moderate', $topic_id ) ) {2093 return;2094 } 2095 2096 $uri = add_query_arg( array(2097 'action' => 'move',2098 'reply_id' => $reply_id2099 ), bbp_get_reply_edit_url( $reply_id ) );2100 2101 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-reply-move-link">' . $r['split_text'] . '</a>' . $r['link_after'];2102 2103 // Filter & return2104 return apply_filters( 'bbp_get_reply_move_link', $retval, $r, $args );2105 }2127 // Get IDs 2128 $reply_id = bbp_get_reply_id( $r['id'] ); 2129 $topic_id = bbp_get_reply_topic_id( $reply_id ); 2130 2131 // Bail if no reply ID or user cannot moderate 2132 if ( empty( $reply_id ) || ! current_user_can( 'moderate', $topic_id ) ) { 2133 return; 2134 } 2135 2136 $uri = add_query_arg( array( 2137 'action' => 'move', 2138 'reply_id' => $reply_id 2139 ), bbp_get_reply_edit_url( $reply_id ) ); 2140 2141 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-reply-move-link">' . $r['split_text'] . '</a>' . $r['link_after']; 2142 2143 // Filter & return 2144 return apply_filters( 'bbp_get_reply_move_link', $retval, $r, $args ); 2145 } 2106 2146 2107 2147 /** … … 2118 2158 } 2119 2159 2120 /**2121 * Get split topic link2122 *2123 * Return the split link of the topic (but is bundled with each reply)2124 *2125 * @since 2.0.0 bbPress (r2756)2126 *2127 * @param array $args This function supports these arguments:2128 * - id: Reply id2129 * - link_before: HTML before the link2130 * - link_after: HTML after the link2131 * - split_text: Split text2132 * - split_title: Split title attribute2133 * @return string Topic split link2134 */2135 function bbp_get_topic_split_link( $args = array() ) {2160 /** 2161 * Get split topic link 2162 * 2163 * Return the split link of the topic (but is bundled with each reply) 2164 * 2165 * @since 2.0.0 bbPress (r2756) 2166 * 2167 * @param array $args This function supports these arguments: 2168 * - id: Reply id 2169 * - link_before: HTML before the link 2170 * - link_after: HTML after the link 2171 * - split_text: Split text 2172 * - split_title: Split title attribute 2173 * @return string Topic split link 2174 */ 2175 function bbp_get_topic_split_link( $args = array() ) { 2136 2176 2137 2177 // Parse arguments against default values 2138 2178 $r = bbp_parse_args( $args, array( 2139 'id' => 0,2140 'link_before' => '',2141 'link_after' => '',2142 'split_text' => esc_html__( 'Split', 'bbpress' ),2143 'split_title' => esc_attr__( 'Split the topic from this reply', 'bbpress' )2179 'id' => 0, 2180 'link_before' => '', 2181 'link_after' => '', 2182 'split_text' => esc_html__( 'Split', 'bbpress' ), 2183 'split_title' => esc_attr__( 'Split the topic from this reply', 'bbpress' ) 2144 2184 ), 'get_topic_split_link' ); 2145 2185 2146 // Get IDs2147 $reply_id = bbp_get_reply_id( $r['id'] );2148 $topic_id = bbp_get_reply_topic_id( $reply_id );2149 2150 // Bail if no reply/topic ID, or user cannot moderate2151 if ( empty( $reply_id ) || empty( $topic_id ) || ! current_user_can( 'moderate', $topic_id ) ) {2152 return;2153 } 2154 2155 $uri = add_query_arg( array(2156 'action' => 'split',2157 'reply_id' => $reply_id2158 ), bbp_get_topic_edit_url( $topic_id ) );2159 2160 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-topic-split-link">' . $r['split_text'] . '</a>' . $r['link_after'];2161 2162 // Filter & return2163 return apply_filters( 'bbp_get_topic_split_link', $retval, $r, $args );2164 }2186 // Get IDs 2187 $reply_id = bbp_get_reply_id( $r['id'] ); 2188 $topic_id = bbp_get_reply_topic_id( $reply_id ); 2189 2190 // Bail if no reply/topic ID, or user cannot moderate 2191 if ( empty( $reply_id ) || empty( $topic_id ) || ! current_user_can( 'moderate', $topic_id ) ) { 2192 return; 2193 } 2194 2195 $uri = add_query_arg( array( 2196 'action' => 'split', 2197 'reply_id' => $reply_id 2198 ), bbp_get_topic_edit_url( $topic_id ) ); 2199 2200 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" title="' . $r['split_title'] . '" class="bbp-topic-split-link">' . $r['split_text'] . '</a>' . $r['link_after']; 2201 2202 // Filter & return 2203 return apply_filters( 'bbp_get_topic_split_link', $retval, $r, $args ); 2204 } 2165 2205 2166 2206 /** … … 2175 2215 } 2176 2216 2177 /**2178 * Return the approve link of the reply2179 *2180 * @since 2.6.0 bbPress (r5507)2181 *2182 * @param array $args This function supports these args:2183 * - id: Optional. Reply id2184 * - link_before: Before the link2185 * - link_after: After the link2186 * - sep: Separator between links2187 * - approve_text: Approve text2188 * - unapprove_text: Unapprove text2189 * @return string Reply approve link2190 */2191 function bbp_get_reply_approve_link( $args = array() ) {2217 /** 2218 * Return the approve link of the reply 2219 * 2220 * @since 2.6.0 bbPress (r5507) 2221 * 2222 * @param array $args This function supports these args: 2223 * - id: Optional. Reply id 2224 * - link_before: Before the link 2225 * - link_after: After the link 2226 * - sep: Separator between links 2227 * - approve_text: Approve text 2228 * - unapprove_text: Unapprove text 2229 * @return string Reply approve link 2230 */ 2231 function bbp_get_reply_approve_link( $args = array() ) { 2192 2232 2193 2233 // Parse arguments against default values 2194 2234 $r = bbp_parse_args( $args, array( 2195 'id' => 0,2196 'link_before' => '',2197 'link_after' => '',2198 'sep' => ' | ',2199 'approve_text' => _x( 'Approve', 'Pending Status', 'bbpress' ),2200 'unapprove_text' => _x( 'Unapprove', 'Pending Status', 'bbpress' )2235 'id' => 0, 2236 'link_before' => '', 2237 'link_after' => '', 2238 'sep' => ' | ', 2239 'approve_text' => _x( 'Approve', 'Pending Status', 'bbpress' ), 2240 'unapprove_text' => _x( 'Unapprove', 'Pending Status', 'bbpress' ) 2201 2241 ), 'get_reply_approve_link' ); 2202 2242 2203 // Get reply2204 $reply = bbp_get_reply( $r['id'] );2205 2206 // Bail if no reply or current user cannot moderate2207 if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) {2208 return;2209 } 2210 2211 $display = bbp_is_reply_pending( $reply->ID ) ? $r['approve_text'] : $r['unapprove_text'];2212 $uri = add_query_arg( array( 'action' => 'bbp_toggle_reply_approve', 'reply_id' => $reply->ID ) );2213 $uri = wp_nonce_url( $uri, 'approve-reply_' . $reply->ID );2214 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-approve-link">' . $display . '</a>' . $r['link_after'];2215 2216 // Filter & return2217 return apply_filters( 'bbp_get_reply_approve_link', $retval, $r, $args );2218 }2243 // Get reply 2244 $reply = bbp_get_reply( $r['id'] ); 2245 2246 // Bail if no reply or current user cannot moderate 2247 if ( empty( $reply ) || ! current_user_can( 'moderate', $reply->ID ) ) { 2248 return; 2249 } 2250 2251 $display = bbp_is_reply_pending( $reply->ID ) ? $r['approve_text'] : $r['unapprove_text']; 2252 $uri = add_query_arg( array( 'action' => 'bbp_toggle_reply_approve', 'reply_id' => $reply->ID ) ); 2253 $uri = wp_nonce_url( $uri, 'approve-reply_' . $reply->ID ); 2254 $retval = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-approve-link">' . $display . '</a>' . $r['link_after']; 2255 2256 // Filter & return 2257 return apply_filters( 'bbp_get_reply_approve_link', $retval, $r, $args ); 2258 } 2219 2259 2220 2260 /** … … 2229 2269 echo bbp_get_reply_class( $reply_id, $classes ); 2230 2270 } 2231 /** 2232 * Return the row class of a reply 2233 * 2234 * @since 2.0.0 bbPress (r2678) 2235 * 2236 * @param int $reply_id Optional. Reply ID 2237 * @param array Extra classes you can pass when calling this function 2238 * @return string Row class of the reply 2239 */ 2240 function bbp_get_reply_class( $reply_id = 0, $classes = array() ) { 2271 2272 /** 2273 * Return the row class of a reply 2274 * 2275 * @since 2.0.0 bbPress (r2678) 2276 * 2277 * @param int $reply_id Optional. Reply ID 2278 * @param array Extra classes you can pass when calling this function 2279 * @return string Row class of the reply 2280 */ 2281 function bbp_get_reply_class( $reply_id = 0, $classes = array() ) { 2241 2282 $bbp = bbpress(); 2242 2283 $reply_id = bbp_get_reply_id( $reply_id ); … … 2247 2288 $classes = array_filter( (array) $classes ); 2248 2289 $count = isset( $bbp->reply_query->current_post ) 2249 ? (int) $bbp->reply_query->current_post2250 : 1;2290 ? (int) $bbp->reply_query->current_post 2291 : 1; 2251 2292 2252 2293 // Stripes 2253 2294 $even_odd = ( $count % 2 ) 2254 ? 'even'2255 : 'odd';2295 ? 'even' 2296 : 'odd'; 2256 2297 2257 2298 // Forum moderator replied to topic 2258 2299 $forum_moderator = ( bbp_is_user_forum_moderator( $author_id, $forum_id ) === $author_id ) 2259 ? 'forum-mod'2260 : '';2300 ? 'forum-mod' 2301 : ''; 2261 2302 2262 2303 // Topic author replied to others 2263 2304 $topic_author = ( bbp_get_topic_author_id( $topic_id ) === $author_id ) 2264 ? 'topic-author'2265 : '';2305 ? 'topic-author' 2306 : ''; 2266 2307 2267 2308 // Get reply classes 2268 2309 $reply_classes = array( 2269 'loop-item-' . $count,2270 'user-id-' . $author_id,2271 'bbp-parent-forum-' . $forum_id,2272 'bbp-parent-topic-' . $topic_id,2273 'bbp-reply-position-' . $reply_pos,2274 $even_odd,2275 $topic_author,2276 $forum_moderator2310 'loop-item-' . $count, 2311 'user-id-' . $author_id, 2312 'bbp-parent-forum-' . $forum_id, 2313 'bbp-parent-topic-' . $topic_id, 2314 'bbp-reply-position-' . $reply_pos, 2315 $even_odd, 2316 $topic_author, 2317 $forum_moderator 2277 2318 ); 2278 2319 … … 2286 2327 // Return 2287 2328 return 'class="' . implode( ' ', $new_classes ) . '"'; 2288 }2329 } 2289 2330 2290 2331 /** Pagination ****************************************************************/ … … 2343 2384 echo bbp_get_topic_pagination_count(); 2344 2385 } 2345 /** 2346 * Return the topic pagination count 2347 * 2348 * @since 2.0.0 bbPress (r2519) 2349 * 2350 * @return string Topic pagination count 2351 */ 2352 function bbp_get_topic_pagination_count() { 2386 2387 /** 2388 * Return the topic pagination count 2389 * 2390 * @since 2.0.0 bbPress (r2519) 2391 * 2392 * @return string Topic pagination count 2393 */ 2394 function bbp_get_topic_pagination_count() { 2353 2395 $bbp = bbpress(); 2354 2396 … … 2362 2404 $start_int = intval( ( $bbp->reply_query->paged - 1 ) * $ppp_int ) + 1; 2363 2405 $to_int = intval( ( $start_int + ( $ppp_int - 1 ) > $total_int ) 2364 ? $total_int 2365 : $start_int + ( $ppp_int - 1 ) ); 2366 2367 // Format numbers for display 2368 $count_num = bbp_number_format( $count_int ); 2369 $total_num = bbp_number_format( $total_int ); 2370 $from_num = bbp_number_format( $start_int ); 2371 $to_num = bbp_number_format( $to_int ); 2372 2373 // We are threading replies 2374 if ( bbp_thread_replies() ) { 2375 $walker = new BBP_Walker_Reply(); 2376 $threads = absint( $walker->get_number_of_root_elements( $bbp->reply_query->posts ) - 1 ); 2377 $retstr = sprintf( _n( 'Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbpress' ), bbp_number_format( $threads ) ); 2406 ? $total_int 2407 : $start_int + ( $ppp_int - 1 ) ); 2408 2409 // Format numbers for display 2410 $count_num = bbp_number_format( $count_int ); 2411 $total_num = bbp_number_format( $total_int ); 2412 $from_num = bbp_number_format( $start_int ); 2413 $to_num = bbp_number_format( $to_int ); 2414 2415 // We are threading replies 2416 if ( bbp_thread_replies() ) { 2417 $walker = new BBP_Walker_Reply(); 2418 $threads = absint( $walker->get_number_of_root_elements( $bbp->reply_query->posts ) - 1 ); 2419 /* translators: %s: Number of reply threads */ 2420 $retstr = sprintf( _n( 'Viewing %1$s reply thread', 'Viewing %1$s reply threads', $threads, 'bbpress' ), bbp_number_format( $threads ) ); 2378 2421 2379 2422 // We are not including the lead topic 2380 2423 } elseif ( bbp_show_lead_topic() ) { 2381 2424 2382 // Several replies in a topic with a single page 2383 if ( empty( $to_num ) ) { 2384 $retstr = sprintf( _n( 'Viewing %1$s reply', 'Viewing %1$s replies', $total_int, 'bbpress' ), $total_num ); 2425 // Several replies in a topic with a single page 2426 if ( empty( $to_num ) ) { 2427 /* translators: %1$s: Number of replies */ 2428 $retstr = sprintf( _n( 'Viewing %1$s reply', 'Viewing %1$s replies', $total_int, 'bbpress' ), $total_num ); 2385 2429 2386 2430 // Several replies in a topic with several pages 2387 2431 } else { 2388 $retstr = sprintf( _n( 'Viewing %2$s replies (of %4$s total)', 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num ); //phpcs:ignore 2432 /* translators: 1: Number of replies being viewed, 2: Starting reply number, 3: Ending reply number, 4: Total replies */ 2433 $retstr = sprintf( _n( 'Viewing %2$s replies (of %4$s total)', 'Viewing %1$s replies - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num ); //phpcs:ignore 2389 2434 } 2390 2435 … … 2392 2437 } else { 2393 2438 2394 // Several posts in a topic with a single page 2395 if ( empty( $to_num ) ) { 2439 // Several posts in a topic with a single page 2440 if ( empty( $to_num ) ) { 2441 /* translators: %1$s: Number of posts */ 2396 2442 $retstr = sprintf( _n( 'Viewing %1$s post', 'Viewing %1$s posts', $total_int, 'bbpress' ), $total_num ); 2397 2443 2398 // Several posts in a topic with several pages 2399 } else { 2400 $retstr = sprintf( _n( 'Viewing %2$s post (of %4$s total)', 'Viewing %1$s posts - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num ); //phpcs:ignore 2444 // Several posts in a topic with several pages 2445 } else { 2446 /* translators: 1: Number of posts being viewed, 2: Starting post number, 3: Ending post number, 4: Total posts */ 2447 $retstr = sprintf( _n( 'Viewing %2$s post (of %4$s total)', 'Viewing %1$s posts - %2$s through %3$s (of %4$s total)', $count_int, 'bbpress' ), $count_num, $from_num, $to_num, $total_num ); //phpcs:ignore 2401 2448 } 2402 2449 } 2403 2450 2404 // Escape results of _n()2405 $retstr = esc_html( $retstr );2406 2407 // Filter & return2408 return apply_filters( 'bbp_get_topic_pagination_count', $retstr );2409 }2451 // Escape results of _n() 2452 $retstr = esc_html( $retstr ); 2453 2454 // Filter & return 2455 return apply_filters( 'bbp_get_topic_pagination_count', $retstr ); 2456 } 2410 2457 2411 2458 /** … … 2417 2464 echo bbp_get_topic_pagination_links(); 2418 2465 } 2419 /** 2420 * Return topic pagination links 2421 * 2422 * @since 2.0.0 bbPress (r2519) 2423 * 2424 * @return string Topic pagination links 2425 */ 2426 function bbp_get_topic_pagination_links() { 2466 2467 /** 2468 * Return topic pagination links 2469 * 2470 * @since 2.0.0 bbPress (r2519) 2471 * 2472 * @return string Topic pagination links 2473 */ 2474 function bbp_get_topic_pagination_links() { 2427 2475 $bbp = bbpress(); 2428 2476 2429 2477 if ( ! isset( $bbp->reply_query->pagination_links ) || empty( $bbp->reply_query->pagination_links ) ) { 2430 2478 return false; 2431 }2479 } 2432 2480 2433 2481 // Filter & return 2434 2482 return apply_filters( 'bbp_get_topic_pagination_links', $bbp->reply_query->pagination_links ); 2435 }2483 } 2436 2484 2437 2485 /** Forms *********************************************************************/ … … 2445 2493 echo bbp_get_form_reply_content(); 2446 2494 } 2447 /** 2448 * Return the value of reply content field 2449 * 2450 * @since 2.0.0 bbPress (r3130) 2451 * 2452 * @return string Value of reply content field 2453 */ 2454 function bbp_get_form_reply_content() { 2495 2496 /** 2497 * Return the value of reply content field 2498 * 2499 * @since 2.0.0 bbPress (r3130) 2500 * 2501 * @return string Value of reply content field 2502 */ 2503 function bbp_get_form_reply_content() { 2455 2504 2456 2505 // Get _POST data … … 2458 2507 $reply_content = wp_unslash( $_POST['bbp_reply_content'] ); 2459 2508 2460 // Get edit data2461 } elseif ( bbp_is_reply_edit() ) {2509 // Get edit data 2510 } elseif ( bbp_is_reply_edit() ) { 2462 2511 $reply_content = bbp_get_global_post_field( 'post_content', 'raw' ); 2463 2512 2464 // No data2465 } else {2513 // No data 2514 } else { 2466 2515 $reply_content = ''; 2467 }2516 } 2468 2517 2469 2518 // Filter & return 2470 2519 return apply_filters( 'bbp_get_form_reply_content', $reply_content ); 2471 }2520 } 2472 2521 2473 2522 /** … … 2480 2529 } 2481 2530 2482 /**2483 * Return the value of reply to field2484 *2485 * @since 2.4.0 bbPress (r4944)2486 *2487 * @return string Value of reply to field2488 */2489 function bbp_get_form_reply_to() {2531 /** 2532 * Return the value of reply to field 2533 * 2534 * @since 2.4.0 bbPress (r4944) 2535 * 2536 * @return string Value of reply to field 2537 */ 2538 function bbp_get_form_reply_to() { 2490 2539 2491 2540 // Set initial value … … 2495 2544 if ( isset( $_REQUEST['bbp_reply_to'] ) ) { 2496 2545 $reply_to = bbp_validate_reply_to( $_REQUEST['bbp_reply_to'] ); 2497 }2546 } 2498 2547 2499 2548 // If empty, get from meta 2500 2549 if ( empty( $reply_to ) ) { 2501 2550 $reply_to = bbp_get_reply_to(); 2502 }2551 } 2503 2552 2504 2553 // Filter & return 2505 2554 return apply_filters( 'bbp_get_form_reply_to', $reply_to ); 2506 }2555 } 2507 2556 2508 2557 /** … … 2517 2566 echo bbp_get_reply_to_dropdown( $reply_id ); 2518 2567 } 2519 /** 2520 * Return a select box allowing to pick which topic/reply a reply belongs. 2521 * 2522 * @since 2.6.0 bbPress (r5387) 2523 * 2524 * @param int $reply_id 2525 * 2526 * @return string The dropdown 2527 */ 2528 function bbp_get_reply_to_dropdown( $reply_id = 0 ) { 2568 2569 /** 2570 * Return a select box allowing to pick which topic/reply a reply belongs. 2571 * 2572 * @since 2.6.0 bbPress (r5387) 2573 * 2574 * @param int $reply_id 2575 * 2576 * @return string The dropdown 2577 */ 2578 function bbp_get_reply_to_dropdown( $reply_id = 0 ) { 2529 2579 2530 2580 // Validate the reply data … … 2535 2585 // Get the replies 2536 2586 $posts = get_posts( array( 2537 'post_type' => bbp_get_reply_post_type(),2538 'post_status' => bbp_get_public_status_id(),2539 'post_parent' => $topic_id,2540 'numberposts' => -1,2541 'orderby' => 'menu_order',2542 'order' => 'ASC',2587 'post_type' => bbp_get_reply_post_type(), 2588 'post_status' => bbp_get_public_status_id(), 2589 'post_parent' => $topic_id, 2590 'numberposts' => -1, 2591 'orderby' => 'menu_order', 2592 'order' => 'ASC', 2543 2593 ) ); 2544 2594 2545 // Append `reply_to` for each reply so it can be walked2546 foreach ( $posts as &$post ) {2547 2548 // Check for reply post type2549 $_reply_to = bbp_get_reply_to( $post->ID );2550 2551 // Make sure it's a reply to a reply2552 if ( empty( $_reply_to ) || ( $topic_id === $_reply_to ) ) {2553 $_reply_to = 0;2595 // Append `reply_to` for each reply so it can be walked 2596 foreach ( $posts as &$post ) { 2597 2598 // Check for reply post type 2599 $_reply_to = bbp_get_reply_to( $post->ID ); 2600 2601 // Make sure it's a reply to a reply 2602 if ( empty( $_reply_to ) || ( $topic_id === $_reply_to ) ) { 2603 $_reply_to = 0; 2554 2604 } 2555 2605 2556 // Add reply_to to the post object so we can walk it later 2557 $post->reply_to = $_reply_to; 2558 } 2559 2560 // Default "None" text 2561 $show_none = ( 0 === $reply_id ) 2562 ? esc_attr_x( 'None', 'Default reply to dropdown text', 'bbpress' ) 2563 : sprintf( esc_attr__( '%1$s - %2$s', 'bbpress' ), $topic_id, bbp_get_topic_title( $topic_id ) ); 2564 2565 // Get the dropdown and return it 2566 $retval = bbp_get_dropdown( array( 2567 'show_none' => $show_none, 2568 'select_id' => 'bbp_reply_to', 2569 'select_class' => 'bbp_dropdown', 2570 'exclude' => $reply_id, 2571 'selected' => $reply_to, 2572 'post_parent' => $topic_id, 2573 'post_type' => bbp_get_reply_post_type(), 2574 'max_depth' => bbp_thread_replies_depth(), 2575 'page' => 1, 2576 'per_page' => -1, 2577 'walker' => new BBP_Walker_Reply_Dropdown(), 2578 'posts' => $posts 2579 ) ); 2580 2581 // Filter & return 2582 return apply_filters( 'bbp_get_reply_to_dropdown', $retval, $reply_id, $reply_to, $topic_id ); 2583 } 2606 // Add reply_to to the post object so we can walk it later 2607 $post->reply_to = $_reply_to; 2608 } 2609 2610 // Default "None" text 2611 $show_none = ( 0 === $reply_id ) 2612 ? esc_attr_x( 'None', 'Default reply to dropdown text', 'bbpress' ) 2613 /* translators: 1: Topic ID, 2: Topic title */ 2614 : sprintf( esc_attr__( '%1$s - %2$s', 'bbpress' ), $topic_id, bbp_get_topic_title( $topic_id ) ); 2615 2616 // Get the dropdown and return it 2617 $retval = bbp_get_dropdown( 2618 array( 2619 'show_none' => $show_none, 2620 'select_id' => 'bbp_reply_to', 2621 'select_class' => 'bbp_dropdown', 2622 'exclude' => $reply_id, 2623 'selected' => $reply_to, 2624 'post_parent' => $topic_id, 2625 'post_type' => bbp_get_reply_post_type(), 2626 'max_depth' => bbp_thread_replies_depth(), 2627 'page' => 1, 2628 'per_page' => -1, 2629 'walker' => new BBP_Walker_Reply_Dropdown(), 2630 'posts' => $posts 2631 ) 2632 ); 2633 2634 // Filter & return 2635 return apply_filters( 'bbp_get_reply_to_dropdown', $retval, $reply_id, $reply_to, $topic_id ); 2636 } 2584 2637 2585 2638 /** … … 2591 2644 echo bbp_get_form_reply_log_edit(); 2592 2645 } 2593 /** 2594 * Return checked value of reply log edit field 2595 * 2596 * @since 2.0.0 bbPress (r3130) 2597 * 2598 * @return string Reply log edit checked value 2599 */ 2600 function bbp_get_form_reply_log_edit() { 2646 2647 /** 2648 * Return checked value of reply log edit field 2649 * 2650 * @since 2.0.0 bbPress (r3130) 2651 * 2652 * @return string Reply log edit checked value 2653 */ 2654 function bbp_get_form_reply_log_edit() { 2601 2655 2602 2656 // Get _POST data … … 2604 2658 $reply_revision = (bool) $_POST['bbp_log_reply_edit']; 2605 2659 2606 // No data2607 } else {2660 // No data 2661 } else { 2608 2662 $reply_revision = true; 2609 }2663 } 2610 2664 2611 2665 // Get checked output … … 2614 2668 // Filter & return 2615 2669 return apply_filters( 'bbp_get_form_reply_log_edit', $checked, $reply_revision ); 2616 }2670 } 2617 2671 2618 2672 /** … … 2624 2678 echo bbp_get_form_reply_edit_reason(); 2625 2679 } 2626 /** 2627 * Return the value of the reply edit reason 2628 * 2629 * @since 2.0.0 bbPress (r3130) 2630 * 2631 * @return string Reply edit reason value 2632 */ 2633 function bbp_get_form_reply_edit_reason() { 2680 2681 /** 2682 * Return the value of the reply edit reason 2683 * 2684 * @since 2.0.0 bbPress (r3130) 2685 * 2686 * @return string Reply edit reason value 2687 */ 2688 function bbp_get_form_reply_edit_reason() { 2634 2689 2635 2690 // Get _POST data … … 2637 2692 $reply_edit_reason = wp_unslash( $_POST['bbp_reply_edit_reason'] ); 2638 2693 2639 // No data2640 } else {2694 // No data 2695 } else { 2641 2696 $reply_edit_reason = ''; 2642 }2697 } 2643 2698 2644 2699 // Filter & return 2645 2700 return apply_filters( 'bbp_get_form_reply_edit_reason', $reply_edit_reason ); 2646 }2701 } 2647 2702 2648 2703 /** … … 2660 2715 echo bbp_get_form_reply_status_dropdown( $args ); 2661 2716 } 2662 /** 2663 * Returns reply status dropdown 2664 * 2665 * This dropdown is only intended to be seen by users with the 'moderate' 2666 * capability. Because of this, no additional capability checks are performed 2667 * within this function to check available reply statuses. 2668 * 2669 * @since 2.6.0 bbPress (r5399) 2670 * 2671 * @param $args This function supports these arguments: 2672 * - select_id: Select id. Defaults to bbp_reply_status 2673 * - tab: Deprecated. Tabindex 2674 * - reply_id: Reply id 2675 * - selected: Override the selected option 2676 */ 2677 function bbp_get_form_reply_status_dropdown( $args = array() ) { 2717 2718 /** 2719 * Returns reply status dropdown 2720 * 2721 * This dropdown is only intended to be seen by users with the 'moderate' 2722 * capability. Because of this, no additional capability checks are performed 2723 * within this function to check available reply statuses. 2724 * 2725 * @since 2.6.0 bbPress (r5399) 2726 * 2727 * @param $args This function supports these arguments: 2728 * - select_id: Select id. Defaults to bbp_reply_status 2729 * - tab: Deprecated. Tabindex 2730 * - reply_id: Reply id 2731 * - selected: Override the selected option 2732 */ 2733 function bbp_get_form_reply_status_dropdown( $args = array() ) { 2678 2734 2679 2735 // Parse arguments against default values 2680 2736 $r = bbp_parse_args( $args, array( 2681 'select_id' => 'bbp_reply_status',2682 'select_class' => 'bbp_dropdown',2683 'tab' => false,2684 'reply_id' => 0,2685 'selected' => false2737 'select_id' => 'bbp_reply_status', 2738 'select_class' => 'bbp_dropdown', 2739 'tab' => false, 2740 'reply_id' => 0, 2741 'selected' => false 2686 2742 ), 'reply_status_dropdown' ); 2687 2743 2688 // No specific selected value passed2689 if ( empty( $r['selected'] ) ) {2690 2691 // Post value is passed2692 if ( bbp_is_reply_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {2693 $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] );2744 // No specific selected value passed 2745 if ( empty( $r['selected'] ) ) { 2746 2747 // Post value is passed 2748 if ( bbp_is_reply_form_post_request() && isset( $_POST[ $r['select_id'] ] ) ) { 2749 $r['selected'] = sanitize_key( $_POST[ $r['select_id'] ] ); 2694 2750 2695 2751 // No Post value was passed 2696 2752 } else { 2697 2753 2698 // Edit reply2699 if ( bbp_is_reply_edit() ) {2700 $r['reply_id'] = bbp_get_reply_id( $r['reply_id'] );2701 $r['selected'] = bbp_get_reply_status( $r['reply_id'] );2754 // Edit reply 2755 if ( bbp_is_reply_edit() ) { 2756 $r['reply_id'] = bbp_get_reply_id( $r['reply_id'] ); 2757 $r['selected'] = bbp_get_reply_status( $r['reply_id'] ); 2702 2758 2703 2759 // New reply 2704 2760 } else { 2705 $r['selected'] = bbp_get_public_status_id();2761 $r['selected'] = bbp_get_public_status_id(); 2706 2762 } 2707 }2708 } 2709 2710 // Start an output buffer, we'll finish it after the select loop2711 ob_start(); ?>2712 2713 <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>>2714 2715 <?php foreach ( bbp_get_reply_statuses( $r['reply_id'] ) as $key => $label ) : ?>2716 2717 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>2718 2719 <?php endforeach; ?>2720 2721 </select>2722 2723 <?php2724 2725 // Filter & return2726 return apply_filters( 'bbp_get_form_reply_status_dropdown', ob_get_clean(), $r, $args );2727 }2763 } 2764 } 2765 2766 // Start an output buffer, we'll finish it after the select loop 2767 ob_start(); ?> 2768 2769 <select name="<?php echo esc_attr( $r['select_id'] ); ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select" class="<?php echo esc_attr( $r['select_class'] ); ?>"<?php bbp_tab_index_attribute( $r['tab'] ); ?>> 2770 2771 <?php foreach ( bbp_get_reply_statuses( $r['reply_id'] ) as $key => $label ) : ?> 2772 2773 <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option> 2774 2775 <?php endforeach; ?> 2776 2777 </select> 2778 2779 <?php 2780 2781 // Filter & return 2782 return apply_filters( 'bbp_get_form_reply_status_dropdown', ob_get_clean(), $r, $args ); 2783 } 2728 2784 2729 2785 /** -
trunk/src/includes/search/template.php
r7357 r7360 174 174 // Include search terms in title 175 175 } else { 176 /* translators: %s: Search query terms */ 176 177 $title = sprintf( esc_html__( "Search Results for '%s'", 'bbpress' ), esc_attr( $search_terms ) ); 177 178 } … … 381 382 } 382 383 383 /** 384 * Return the search results pagination count 385 * 386 * @since 2.3.0 bbPress (r4579) 387 * 388 * @return string Search pagination count 389 */ 390 function bbp_get_search_pagination_count() { 391 $bbp = bbpress(); 392 393 // Define local variable(s) 394 $retstr = ''; 395 396 // Set pagination values 397 $total_int = intval( $bbp->search_query->found_posts ); 398 $ppp_int = intval( $bbp->search_query->posts_per_page ); 399 $start_int = intval( ( $bbp->search_query->paged - 1 ) * $ppp_int ) + 1; 400 $to_int = intval( ( $start_int + ( $ppp_int - 1 ) > $total_int ) 401 ? $total_int 402 : $start_int + ( $ppp_int - 1 ) ); 403 404 // Format numbers for display 405 $total_num = bbp_number_format( $total_int ); 406 $from_num = bbp_number_format( $start_int ); 407 $to_num = bbp_number_format( $to_int ); 408 409 // Single page of results 410 if ( empty( $to_num ) ) { 411 $retstr = sprintf( _n( 'Viewing %1$s result', 'Viewing %1$s results', $total_int, 'bbpress' ), $total_num ); 412 413 // Several pages of results 414 } else { 415 $retstr = sprintf( _n( 'Viewing %2$s results (of %4$s total)', 'Viewing %1$s results - %2$s through %3$s (of %4$s total)', $bbp->search_query->post_count, 'bbpress' ), $bbp->search_query->post_count, $from_num, $to_num, $total_num ); //phpcs:ignore 416 } 384 /** 385 * Return the search results pagination count 386 * 387 * @since 2.3.0 bbPress (r4579) 388 * 389 * @return string Search pagination count 390 */ 391 function bbp_get_search_pagination_count() { 392 $bbp = bbpress(); 393 394 // Define local variable(s) 395 $retstr = ''; 396 397 // Set pagination values 398 $total_int = intval( $bbp->search_query->found_posts ); 399 $ppp_int = intval( $bbp->search_query->posts_per_page ); 400 $start_int = intval( ( $bbp->search_query->paged - 1 ) * $ppp_int ) + 1; 401 $to_int = intval( ( $start_int + ( $ppp_int - 1 ) > $total_int ) 402 ? $total_int 403 : $start_int + ( $ppp_int - 1 ) ); 404 405 // Format numbers for display 406 $total_num = bbp_number_format( $total_int ); 407 $from_num = bbp_number_format( $start_int ); 408 $to_num = bbp_number_format( $to_int ); 409 410 // Single page of results 411 if ( empty( $to_num ) ) { 412 $retstr = sprintf( 413 /* translators: %1$s: Number of results */ 414 _n( 'Viewing %1$s result', 'Viewing %1$s results', $total_int, 'bbpress' ), 415 $total_num 416 ); 417 418 // Several pages of results 419 } else { 420 $retstr = sprintf( 421 /* translators: 1: Number of results being viewed, 2: First result number, 3: Last result number, 4: Total results */ 422 _n( 423 'Viewing %1$s result - %2$s through %3$s (of %4$s total)', 424 'Viewing %1$s results - %2$s through %3$s (of %4$s total)', 425 $bbp->search_query->post_count, 426 'bbpress' 427 ), 428 $bbp->search_query->post_count, 429 $from_num, 430 $to_num, 431 $total_num 432 ); 417 433 418 434 // Filter & return 419 435 return apply_filters( 'bbp_get_search_pagination_count', esc_html( $retstr ) ); 420 436 } 437 } 421 438 422 439 /** -
trunk/src/includes/topics/functions.php
r7357 r7360 413 413 // WP_Error 414 414 } elseif ( is_wp_error( $topic_id ) ) { 415 /* translators: %s: Error message(s) */ 415 416 bbp_add_error( 'bbp_topic_error', sprintf( __( '<strong>Error</strong>: The following problem(s) occurred: %s', 'bbpress' ), $topic_id->get_error_message() ) ); 416 417 … … 760 761 } else { 761 762 $append_error = ( is_wp_error( $topic_id ) && $topic_id->get_error_message() ) ? $topic_id->get_error_message() . ' ' : ''; 763 /* translators: %s: Error message(s) */ 762 764 bbp_add_error( 'bbp_topic_error', sprintf( esc_html_e( '<strong>Error</strong>: The following problem(s) have been found with your topic: %s. Please try again.', 'bbpress' ) ), $append_error ); 763 765 } … … 1746 1748 // Tag does not exist 1747 1749 if ( is_wp_error( $tag ) && $tag->get_error_message() ) { 1750 /* translators: %s: Error message(s) */ 1748 1751 bbp_add_error( 'bbp_manage_topic_invalid_tag', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while getting the tag: %s', 'bbpress' ), $tag->get_error_message() ) ); 1749 1752 return; … … 1785 1788 // Cannot update tag 1786 1789 if ( is_wp_error( $tag ) && $tag->get_error_message() ) { 1790 /* translators: %s: Error message(s) */ 1787 1791 bbp_add_error( 'bbp_manage_topic_tag_update_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while updating the tag: %s', 'bbpress' ), $tag->get_error_message() ) ); 1788 1792 return; … … 1825 1829 // Problem inserting the new term 1826 1830 if ( is_wp_error( $tag ) && $tag->get_error_message() ) { 1831 /* translators: %s: Error message(s) */ 1827 1832 bbp_add_error( 'bbp_manage_topic_tag_merge_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while merging the tags: %s', 'bbpress' ), $tag->get_error_message() ) ); 1828 1833 return; … … 1846 1851 // Error merging the terms 1847 1852 if ( is_wp_error( $tag ) && $tag->get_error_message() ) { 1853 /* translators: %s: Error message(s) */ 1848 1854 bbp_add_error( 'bbp_manage_topic_tag_merge_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while merging the tags: %s', 'bbpress' ), $tag->get_error_message() ) ); 1849 1855 return; … … 1878 1884 // Error deleting term 1879 1885 if ( is_wp_error( $tag ) && $tag->get_error_message() ) { 1886 /* translators: %s: Error message(s) */ 1880 1887 bbp_add_error( 'bbp_manage_topic_tag_delete_error', sprintf( __( '<strong>Error</strong>: The following problem(s) have been found while deleting the tag: %s', 'bbpress' ), $tag->get_error_message() ) ); 1881 1888 return; … … 3856 3863 <description> 3857 3864 <![CDATA[ 3858 <p><?php printf( esc_html__( 'Replies: %s', 'bbpress' ), bbp_get_topic_reply_count() ); ?></p> 3865 <p> 3866 <?php 3867 printf( 3868 /* translators: %s: Number of replies to the topic */ 3869 esc_html__( 'Replies: %s', 'bbpress' ), 3870 bbp_get_topic_reply_count() 3871 ); 3872 ?> 3873 </p> 3859 3874 <?php bbp_topic_content(); ?> 3860 3875 ]]> -
trunk/src/includes/topics/template.php
r7357 r7360 764 764 $date = get_post_time( get_option( 'date_format' ), $gmt, $topic_id, true ); 765 765 $time = get_post_time( get_option( 'time_format' ), $gmt, $topic_id, true ); 766 /* translators: 1: Date, 2: Time */ 766 767 $result = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbpress' ), $date, $time ); 767 768 } … … 930 931 $retval .= "\t" . '<li id="bbp-topic-revision-log-' . esc_attr( $topic_id ) . '-item-' . esc_attr( $revision->ID ) . '" class="bbp-topic-revision-log-item">' . "\n"; 931 932 if ( ! empty( $reason ) ) { 933 /* translators: 1: Time since modification, 2: Author link, 3: Modification reason */ 932 934 $retval .= "\t\t" . sprintf( esc_html__( 'This topic was modified %1$s by %2$s. Reason: %3$s', 'bbpress' ), esc_html( $since ), $author, esc_html( $reason ) ) . "\n"; 933 935 } else { 936 /* translators: 1: Time since modification, 2: Author link */ 934 937 $retval .= "\t\t" . sprintf( esc_html__( 'This topic was modified %1$s by %2$s.', 'bbpress' ), esc_html( $since ), $author ) . "\n"; 935 938 } … … 1238 1241 */ 1239 1242 function bbp_topic_author( $topic_id = 0 ) { 1240 echo bbp_get_topic_author ( $topic_id );1243 echo bbp_get_topic_author_display_name( $topic_id ); 1241 1244 } 1242 1245 /** … … 1426 1429 $author = bbp_get_topic_author_display_name( $topic_id ); 1427 1430 $title = empty( $anonymous ) 1431 /* translators: %s: Author's name */ 1428 1432 ? esc_attr__( "View %s's profile", 'bbpress' ) 1433 /* translators: %s: Author's name */ 1429 1434 : esc_attr__( "Visit %s's website", 'bbpress' ); 1430 1435 … … 2013 2018 $topic_id = bbp_get_topic_id( $topic_id ); 2014 2019 $link = bbp_get_topic_permalink( $topic_id ); 2020 /* translators: %s: Number of replies */ 2015 2021 $replies = sprintf( _n( '%s reply', '%s replies', bbp_get_topic_reply_count( $topic_id, true ), 'bbpress' ), bbp_get_topic_reply_count( $topic_id, false ) ); 2016 2022 … … 2028 2034 // Hidden replies 2029 2035 $deleted_num = bbp_get_topic_reply_count_hidden( $topic_id, false ); 2036 /* translators: %s: Number of hidden replies */ 2030 2037 $extra = ' ' . sprintf( _n( '(+%s hidden)', '(+%s hidden)', $deleted_int, 'bbpress' ), $deleted_num ); 2031 2038 … … 2992 2999 // Several topics in a forum with a single page 2993 3000 if ( empty( $to_num ) ) { 3001 /* translators: %1$s: Total number of topics */ 2994 3002 $retstr = sprintf( _n( 'Viewing %1$s topic', 'Viewing %1$s topics', $total_int, 'bbpress' ), $total ); 2995 3003 … … 3313 3321 3314 3322 // Singular/Plural 3323 /* translators: %s: Number of voices/participants */ 3315 3324 $voice_count = sprintf( _n( '%s voice', '%s voices', $vc_int, 'bbpress' ), $voice_count ); 3316 3325 … … 3320 3329 3321 3330 // Last-updated-by should always exist if last-active does 3322 $last_updated_by = bbp_get_author_link( array( 3323 'post_id' => $last_active, 3324 'size' => $r['size'] 3325 ) ); 3331 $last_updated_by = bbp_get_author_link( 3332 array( 3333 'post_id' => $last_active, 3334 'size' => $r['size'] 3335 ) 3336 ); 3326 3337 3327 3338 // Voice count is non-zero (registered users engaged) 3328 3339 if ( ! empty( $vc_int ) ) { 3340 /* translators: 1: Reply count, 2: Voice count, 3: Last updated time, 4: Last updated by */ 3329 3341 $retstr = sprintf( esc_html__( 'This topic has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $reply_count, $voice_count, $time_since, $last_updated_by ); 3330 3342 3331 3343 // Voice count is zero (anonymous users only) 3332 3344 } else { 3345 /* translators: 1: Last updated time, 2: Last updated by */ 3333 3346 $retstr = sprintf( esc_html__( 'This topic was last updated %1$s by %2$s.', 'bbpress' ), $time_since, $last_updated_by ); 3334 3347 } … … 3336 3349 // Topic has no replies 3337 3350 } elseif ( ! empty( $vc_int ) && ! empty( $reply_count ) ) { 3351 /* translators: 1: Voice count, 2: Reply count */ 3338 3352 $retstr = sprintf( esc_html__( 'This topic has %1$s and %2$s.', 'bbpress' ), $voice_count, $reply_count ); 3339 3353 … … 4035 4049 4036 4050 // Get the text 4051 /* translators: %1$s: Person who is editing (user profile link or "Nobody") */ 4037 4052 $text = sprintf( esc_html__( '%1$s is currently editing this topic.', 'bbpress' ), $person ); 4038 4053 -
trunk/src/includes/users/functions.php
r7245 r7360 416 416 ), $user_url ); 417 417 418 /* translators: 1: Username, 2: Confirmation URL, 3: New email address, 4: Site name, 5: Site URL */ 418 419 $email_text = __( '%1$s 419 420 … … 451 452 452 453 // Build the email subject 454 /* translators: %s: Site name */ 453 455 $subject = sprintf( __( '[%s] New Email Address', 'bbpress' ), wp_specialchars_decode( get_option( 'blogname' ) ) ); 454 456 -
trunk/src/includes/users/template.php
r7352 r7360 1449 1449 <div class="bbp-template-notice info"> 1450 1450 <ul> 1451 <li><?php printf( esc_html__( 'There is a pending email address change to %1$s. %2$s', 'bbpress' ), $coded_email, $dismiss_link ); ?></li> 1451 <li> 1452 <?php 1453 printf( 1454 /* translators: 1: New email address, 2: Dismiss change link */ 1455 esc_html__( 'There is a pending email address change to %1$s. %2$s', 'bbpress' ), 1456 $coded_email, 1457 $dismiss_link 1458 ); 1459 ?></li> 1452 1460 </ul> 1453 1461 </div> … … 2035 2043 $author = get_the_author_meta( 'display_name', $user_id ); 2036 2044 $title = empty( $anonymous ) 2045 /* translators: %s: Author's display name */ 2037 2046 ? esc_attr__( "View %s's profile", 'bbpress' ) 2047 /* translators: %s: Author's display name */ 2038 2048 : esc_attr__( "Visit %s's website", 'bbpress' ); 2039 2049 -
trunk/src/templates/default/bbpress/form-allowed-tags.php
r7268 r7360 14 14 15 15 <p class="form-allowed-tags"> 16 <label><?php printf( esc_html__( 'You may use these %s tags and attributes:', 'bbpress' ), '<abbr title="HyperText Markup Language">HTML</abbr>' ); ?></label><br /> 16 <label> 17 <?php 18 printf( 19 /* translators: %s: Literally the "HTML" string */ 20 esc_html__( 'You may use these %s tags and attributes:', 'bbpress' ), '<abbr title="HyperText Markup Language">HTML</abbr>' ); 21 ?> 22 </label> 23 <br /> 17 24 <code><?php bbp_allowed_tags(); ?></code> 18 25 </p> -
trunk/src/templates/default/bbpress/form-forum.php
r7347 r7360 34 34 <?php 35 35 if ( bbp_is_forum_edit() ) : 36 /* translators: %s: Forum title */ 36 37 printf( esc_html__( 'Editing “%s”', 'bbpress' ), bbp_get_forum_title() ); 37 38 else : 38 39 ( bbp_is_single_forum() && bbp_get_forum_title() ) 40 /* translators: %s: Forum title */ 39 41 ? printf( esc_html__( 'Add Forum in “%s”', 'bbpress' ), bbp_get_forum_title() ) 40 42 : esc_html_e( 'Add Forum', 'bbpress' ); … … 73 75 74 76 <p> 75 <label for="bbp_forum_title"><?php printf( esc_html__( 'Forum Name (Maximum Length: %d):', 'bbpress' ), bbp_get_title_max_length() ); ?></label><br /> 77 <label for="bbp_forum_title"> 78 <?php 79 printf( 80 /* translators: %s: Maximum length of forum title */ 81 esc_html__( 'Forum Name (Maximum Length: %d):', 'bbpress' ), 82 bbp_get_title_max_length() 83 ); 84 ?> 85 </label><br /> 76 86 <input type="text" id="bbp_forum_title" value="<?php bbp_form_forum_title(); ?>" size="40" name="bbp_forum_title" maxlength="<?php bbp_title_max_length(); ?>" /> 77 87 </p> … … 174 184 <div class="bbp-template-notice"> 175 185 <ul> 176 <li><?php printf( esc_html__( 'The forum ‘%s’ is closed to new content.', 'bbpress' ), bbp_get_forum_title() ); ?></li> 186 <li> 187 <?php 188 printf( 189 /* translators: %s: Forum title */ 190 esc_html__( 'The forum ‘%s’ is closed to new content.', 'bbpress' ), 191 bbp_get_forum_title() 192 ); 193 ?> 194 </li> 177 195 </ul> 178 196 </div> -
trunk/src/templates/default/bbpress/form-reply-move.php
r6806 r7360 25 25 <fieldset class="bbp-form"> 26 26 27 <legend><?php printf( esc_html__( 'Move reply "%s"', 'bbpress' ), bbp_get_reply_title() ); ?></legend> 27 <legend> 28 <?php 29 printf( 30 /* translators: %s: Reply title */ 31 esc_html__( 'Move reply "%s"', 'bbpress' ), bbp_get_reply_title() 32 ); 33 ?> 34 </legend> 28 35 29 36 <div> … … 46 53 <div> 47 54 <input name="bbp_reply_move_option" id="bbp_reply_move_option_reply" type="radio" checked="checked" value="topic" /> 48 <label for="bbp_reply_move_option_reply"><?php printf( esc_html__( 'New topic in %s titled:', 'bbpress' ), bbp_get_forum_title( bbp_get_reply_forum_id( bbp_get_reply_id() ) ) ); ?></label> 49 <input type="text" id="bbp_reply_move_destination_title" value="<?php printf( esc_html__( 'Moved: %s', 'bbpress' ), bbp_get_reply_title() ); ?>" size="35" name="bbp_reply_move_destination_title" /> 55 <label for="bbp_reply_move_option_reply"> 56 <?php 57 printf( 58 /* translators: %s: Forum title */ 59 esc_html__( 'New topic in %s titled:', 'bbpress' ), bbp_get_forum_title( bbp_get_reply_forum_id( bbp_get_reply_id() ) ) 60 ); 61 ?> 62 </label> 63 <input type="text" id="bbp_reply_move_destination_title" value=" 64 <?php 65 printf( 66 /* translators: %s: Reply title */ 67 esc_html__( 'Moved: %s', 'bbpress' ), bbp_get_reply_title() 68 ); 69 ?>" size="35" name="bbp_reply_move_destination_title" /> 50 70 </div> 51 71 -
trunk/src/templates/default/bbpress/form-reply.php
r7268 r7360 28 28 29 29 <fieldset class="bbp-form"> 30 <legend><?php printf( esc_html__( 'Reply To: %s', 'bbpress' ), ( bbp_get_form_reply_to() ) ? sprintf( esc_html__( 'Reply #%1$s in %2$s', 'bbpress' ), bbp_get_form_reply_to(), bbp_get_topic_title() ) : bbp_get_topic_title() ); ?></legend> 30 <legend> 31 <?php 32 if ( bbp_get_form_reply_to() ) { 33 34 printf( 35 /* translators: %s: Reply reference (includes reply number and topic title) */ 36 esc_html__( 'Reply To: %s', 'bbpress' ), 37 sprintf( 38 /* translators: 1: Reply number, 2: Topic title */ 39 esc_html__( 'Reply #%1$s in %2$s', 'bbpress' ), 40 bbp_get_form_reply_to(), 41 bbp_get_topic_title() 42 ) 43 ); 44 } else { 45 46 printf( 47 /* translators: %s: Topic title */ 48 esc_html__( 'Reply To: %s', 'bbpress' ), 49 bbp_get_topic_title() 50 ); 51 } 52 ?> 53 </legend> 31 54 32 55 <?php do_action( 'bbp_theme_before_reply_form_notices' ); ?> … … 191 214 <div class="bbp-template-notice"> 192 215 <ul> 193 <li><?php printf( esc_html__( 'The topic ‘%s’ is closed to new replies.', 'bbpress' ), bbp_get_topic_title() ); ?></li> 216 <li> 217 <?php 218 printf( 219 /* translators: %s: Topic title */ 220 esc_html__( 'The topic ‘%s’ is closed to new replies.', 'bbpress' ), 221 bbp_get_topic_title() 222 ); 223 ?> 224 </li> 194 225 </ul> 195 226 </div> … … 201 232 <div class="bbp-template-notice"> 202 233 <ul> 203 <li><?php printf( esc_html__( 'The forum ‘%s’ is closed to new topics and replies.', 'bbpress' ), bbp_get_forum_title( bbp_get_topic_forum_id() ) ); ?></li> 234 <li> 235 <?php 236 printf( 237 /* translators: %s: Forum title */ 238 esc_html__( 'The forum ‘%s’ is closed to new topics and replies.', 'bbpress' ), 239 bbp_get_forum_title( bbp_get_topic_forum_id() ) 240 ); 241 ?> 242 </li> 204 243 </ul> 205 244 </div> -
trunk/src/templates/default/bbpress/form-topic-merge.php
r6806 r7360 25 25 <fieldset class="bbp-form"> 26 26 27 <legend><?php printf( esc_html__( 'Merge topic "%s"', 'bbpress' ), bbp_get_topic_title() ); ?></legend> 27 <legend> 28 <?php 29 printf( 30 /* translators: %s: Topic title */ 31 esc_html__( 'Merge topic "%s"', 'bbpress' ), 32 bbp_get_topic_title() 33 ); 34 ?> 35 </legend> 28 36 29 37 <div> -
trunk/src/templates/default/bbpress/form-topic-split.php
r6806 r7360 25 25 <fieldset class="bbp-form"> 26 26 27 <legend><?php printf( esc_html__( 'Split topic "%s"', 'bbpress' ), bbp_get_topic_title() ); ?></legend> 27 <legend> 28 <?php 29 printf( 30 /* translators: %s: Topic title */ 31 esc_html__( 'Split topic "%s"', 'bbpress' ), 32 bbp_get_topic_title() 33 ); 34 ?> 35 </legend> 28 36 29 37 <div> … … 46 54 <div> 47 55 <input name="bbp_topic_split_option" id="bbp_topic_split_option_reply" type="radio" checked="checked" value="reply" /> 48 <label for="bbp_topic_split_option_reply"><?php printf( esc_html__( 'New topic in %s titled:', 'bbpress' ), bbp_get_forum_title( bbp_get_topic_forum_id( bbp_get_topic_id() ) ) ); ?></label> 49 <input type="text" id="bbp_topic_split_destination_title" value="<?php printf( esc_html__( 'Split: %s', 'bbpress' ), bbp_get_topic_title() ); ?>" size="35" name="bbp_topic_split_destination_title" /> 56 <label for="bbp_topic_split_option_reply"> 57 <?php 58 printf( 59 /* translators: %s: Forum title */ 60 esc_html__( 'New topic in %s titled:', 'bbpress' ), bbp_get_forum_title( bbp_get_topic_forum_id( bbp_get_topic_id() ) ) 61 ); 62 ?> 63 </label> 64 <input type="text" id="bbp_topic_split_destination_title" value=" 65 <?php 66 printf( 67 /* translators: %s: Original topic title */ 68 esc_html__( 'Split: %s', 'bbpress' ), bbp_get_topic_title() 69 ); 70 ?>" size="35" name="bbp_topic_split_destination_title" /> 50 71 </div> 51 72 … … 57 78 58 79 <?php 59 bbp_dropdown( array( 60 'post_type' => bbp_get_topic_post_type(), 61 'post_parent' => bbp_get_topic_forum_id( bbp_get_topic_id() ), 62 'post_status' => bbp_get_public_topic_statuses(), 63 'selected' => -1, 64 'exclude' => bbp_get_topic_id(), 65 'select_id' => 'bbp_destination_topic' 66 ) ); 80 bbp_dropdown( 81 array( 82 'post_type' => bbp_get_topic_post_type(), 83 'post_parent' => bbp_get_topic_forum_id( bbp_get_topic_id() ), 84 'post_status' => bbp_get_public_topic_statuses(), 85 'selected' => -1, 86 'exclude' => bbp_get_topic_id(), 87 'select_id' => 'bbp_destination_topic' 88 ) 89 ); 67 90 ?> 68 91 -
trunk/src/templates/default/bbpress/form-topic-tag.php
r6806 r7360 17 17 <fieldset class="bbp-form" id="bbp-edit-topic-tag"> 18 18 19 <legend><?php printf( esc_html__( 'Manage Tag: "%s"', 'bbpress' ), bbp_get_topic_tag_name() ); ?></legend> 19 <legend> 20 <?php 21 printf( 22 /* translators: %s: Topic tag name */ 23 esc_html__( 'Manage Tag: "%s"', 'bbpress' ), 24 bbp_get_topic_tag_name() 25 ); 26 ?> 27 </legend> 20 28 21 29 <fieldset class="bbp-form" id="tag-rename"> … … 83 91 84 92 <div class="bbp-submit-wrapper"> 85 <button type="submit" class="button submit" onclick="return confirm('<?php echo esc_js( sprintf( esc_html__( 'Are you sure you want to merge the "%s" tag into the tag you specified?', 'bbpress' ), bbp_get_topic_tag_name() ) ); ?>');"><?php esc_attr_e( 'Merge', 'bbpress' ); ?></button> 93 <button type="submit" 94 class="button submit" 95 onclick="return confirm('<?php 96 97 echo esc_js( 98 sprintf( 99 /* translators: %s: Topic tag name */ 100 esc_html__( 101 'Are you sure you want to merge the "%s" tag into the tag you specified?', 102 'bbpress' 103 ), 104 bbp_get_topic_tag_name() 105 ) 106 ); 107 ?>');"> 108 <?php esc_attr_e( 'Merge', 'bbpress' ); ?> 109 </button> 86 110 87 <input type="hidden" name="tag-id" value="<?php bbp_topic_tag_id(); ?>" /> 88 <input type="hidden" name="action" value="bbp-merge-topic-tag" /> 111 <input type="hidden" 112 name="tag-id" 113 value="<?php bbp_topic_tag_id(); ?>" /> 114 115 <input type="hidden" 116 name="action" 117 value="bbp-merge-topic-tag" /> 89 118 90 119 <?php wp_nonce_field( 'merge-tag_' . bbp_get_topic_tag_id() ); ?> … … 113 142 114 143 <form id="delete_tag" name="delete_tag" method="post"> 144 <div class="bbp-submit-wrapper"> 145 <button type="submit" 146 class="button submit" 147 onclick="return confirm('<?php 148 echo esc_js( 149 sprintf( 150 /* translators: %s: Topic tag name */ 151 esc_html__( 152 'Are you sure you want to delete the "%s" tag? This is permanent and cannot be undone.', 153 'bbpress' 154 ), 155 bbp_get_topic_tag_name() 156 ) 157 ); 158 ?>');"> 159 <?php esc_attr_e( 'Delete', 'bbpress' ); ?> 160 </button> 115 161 116 <div class="bbp-submit-wrapper"> 117 <button type="submit" class="button submit" onclick="return confirm('<?php echo esc_js( sprintf( esc_html__( 'Are you sure you want to delete the "%s" tag? This is permanent and cannot be undone.', 'bbpress' ), bbp_get_topic_tag_name() ) ); ?>');"><?php esc_attr_e( 'Delete', 'bbpress' ); ?></button> 162 <input type="hidden" 163 name="tag-id" 164 value="<?php bbp_topic_tag_id(); ?>" /> 118 165 119 <input type="hidden" name="tag-id" value="<?php bbp_topic_tag_id(); ?>" /> 120 <input type="hidden" name="action" value="bbp-delete-topic-tag" /> 166 <input type="hidden" 167 name="action" 168 value="bbp-delete-topic-tag" /> 121 169 122 170 <?php wp_nonce_field( 'delete-tag_' . bbp_get_topic_tag_id() ); ?> -
trunk/src/templates/default/bbpress/form-topic.php
r7347 r7360 42 42 <?php 43 43 if ( bbp_is_topic_edit() ) : 44 /* translators: %s: Topic title */ 44 45 printf( esc_html__( 'Editing “%s”', 'bbpress' ), bbp_get_topic_title() ); 45 46 else : 46 47 ( bbp_is_single_forum() && bbp_get_forum_title() ) 48 /* translators: %s: Topic title */ 47 49 ? printf( esc_html__( 'Add Topic in “%s”', 'bbpress' ), bbp_get_forum_title() ) 48 50 : esc_html_e( 'Add Topic', 'bbpress' ); … … 83 85 84 86 <p> 85 <label for="bbp_topic_title"><?php printf( esc_html__( 'Topic Title (Maximum Length: %d):', 'bbpress' ), bbp_get_title_max_length() ); ?></label><br /> 86 <input type="text" id="bbp_topic_title" value="<?php bbp_form_topic_title(); ?>" size="40" name="bbp_topic_title" maxlength="<?php bbp_title_max_length(); ?>" /> 87 <label for="bbp_topic_title"> 88 <?php 89 printf( 90 /* translators: %d: Maximum allowed length for topic title */ 91 esc_html__( 'Topic Title (Maximum Length: %d):', 'bbpress' ), 92 bbp_get_title_max_length() 93 ); 94 ?> 95 </label> 96 <br /> 97 <input type="text" id="bbp_topic_title" value="<?php bbp_form_topic_title(); ?>" size="40" name="bbp_topic_title" maxlength="<?php bbp_title_max_length(); ?>" 98 /> 87 99 </p> 88 100 … … 228 240 <div class="bbp-template-notice"> 229 241 <ul> 230 <li><?php printf( esc_html__( 'The forum ‘%s’ is closed to new topics and replies.', 'bbpress' ), bbp_get_forum_title() ); ?></li> 242 <li> 243 <?php 244 printf( 245 /* translators: %s: Forum title */ 246 esc_html__( 'The forum ‘%s’ is closed to new topics and replies.', 'bbpress' ), 247 bbp_get_forum_title() 248 ); 249 ?> 250 </li> 231 251 </ul> 232 252 </div> -
trunk/src/templates/default/bbpress/loop-search-forum.php
r6258 r7360 15 15 <div class="bbp-forum-header"> 16 16 <div class="bbp-meta"> 17 <span class="bbp-forum-post-date"><?php printf( esc_html__( 'Last updated %s', 'bbpress' ), bbp_get_forum_last_active_time() ); ?></span> 17 <span class="bbp-forum-post-date"> 18 <?php 19 printf( 20 /* translators: %s: Time since last forum update */ 21 esc_html__( 'Last updated %s', 'bbpress' ), bbp_get_forum_last_active_time() 22 ); 23 ?> 24 </span> 18 25 <a href="<?php bbp_forum_permalink(); ?>" class="bbp-forum-permalink">#<?php bbp_forum_id(); ?></a> 19 26 </div><!-- .bbp-meta --> -
trunk/src/templates/default/bbpress/loop-single-topic.php
r6258 r7360 60 60 <?php do_action( 'bbp_theme_before_topic_started_by' ); ?> 61 61 62 <span class="bbp-topic-started-by"><?php printf( esc_html__( 'Started by: %1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '14' ) ) ); ?></span> 62 <span class="bbp-topic-started-by"> 63 <?php 64 printf( 65 /* translators: %1$s: Topic author link */ 66 esc_html__( 'Started by: %1$s', 'bbpress' ), 67 bbp_get_topic_author_link( array( 'size' => '14' ) ) 68 ); 69 ?> 70 </span> 63 71 64 72 <?php do_action( 'bbp_theme_after_topic_started_by' ); ?> … … 68 76 <?php do_action( 'bbp_theme_before_topic_started_in' ); ?> 69 77 70 <span class="bbp-topic-started-in"><?php printf( esc_html__( 'in: %1$s', 'bbpress' ), '<a href="' . bbp_get_forum_permalink( bbp_get_topic_forum_id() ) . '">' . bbp_get_forum_title( bbp_get_topic_forum_id() ) . '</a>' ); ?></span> 78 <span class="bbp-topic-started-in"> 79 <?php 80 printf( 81 /* translators: %1$s: Forum link with title */ 82 esc_html__( 'in: %1$s', 'bbpress' ), 83 '<a href="' . bbp_get_forum_permalink( bbp_get_topic_forum_id() ) . '">' . bbp_get_forum_title( bbp_get_topic_forum_id() ) . '</a>' 84 ); 85 ?> 86 </span> 71 87 <?php do_action( 'bbp_theme_after_topic_started_in' ); ?> 72 88 -
trunk/src/templates/default/bbpress/user-details.php
r7006 r7360 27 27 <ul> 28 28 <li class="<?php if ( bbp_is_single_user_profile() ) : ?>current<?php endif; ?>"> 29 <span class="vcard bbp-user-profile-link"> 30 <a class="url fn n" href="<?php bbp_user_profile_url(); ?>" title="<?php printf( esc_attr__( "%s's Profile", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>" rel="me"><?php esc_html_e( 'Profile', 'bbpress' ); ?></a> 29 <span class="vcard bbp-user-profile-link"> 30 <a class="url fn n" href="<?php bbp_user_profile_url(); ?>" title=" 31 <?php 32 printf( 33 /* translators: %s: User's display name */ 34 esc_attr__( "%s's Profile", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) 35 ); 36 ?>" rel="me"> 37 <?php esc_html_e( 'Profile', 'bbpress' ); ?> 38 </a> 31 39 </span> 32 40 </li> … … 34 42 <li class="<?php if ( bbp_is_single_user_topics() ) : ?>current<?php endif; ?>"> 35 43 <span class='bbp-user-topics-created-link'> 36 <a href="<?php bbp_user_topics_created_url(); ?>" title="<?php printf( esc_attr__( "%s's Topics Started", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Topics Started', 'bbpress' ); ?></a> 44 <a href="<?php bbp_user_topics_created_url(); ?>" title=" 45 <?php 46 printf( 47 /* translators: %s: User's display name */ 48 esc_attr__( "%s's Topics Started", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) 49 ); 50 ?>"> 51 <?php esc_html_e( 'Topics Started', 'bbpress' ); ?> 52 </a> 37 53 </span> 38 54 </li> … … 40 56 <li class="<?php if ( bbp_is_single_user_replies() ) : ?>current<?php endif; ?>"> 41 57 <span class='bbp-user-replies-created-link'> 42 <a href="<?php bbp_user_replies_created_url(); ?>" title="<?php printf( esc_attr__( "%s's Replies Created", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Replies Created', 'bbpress' ); ?></a> 58 <a href="<?php bbp_user_replies_created_url(); ?>" title=" 59 <?php 60 printf( 61 /* translators: %s: User's display name */ 62 esc_attr__( "%s's Replies Created", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) 63 ); 64 ?>"> 65 <?php esc_html_e( 'Replies Created', 'bbpress' ); ?> 66 </a> 43 67 </span> 44 68 </li> … … 47 71 <li class="<?php if ( bbp_is_single_user_engagements() ) : ?>current<?php endif; ?>"> 48 72 <span class='bbp-user-engagements-created-link'> 49 <a href="<?php bbp_user_engagements_url(); ?>" title="<?php printf( esc_attr__( "%s's Engagements", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Engagements', 'bbpress' ); ?></a> 73 <a href="<?php bbp_user_engagements_url(); ?>" title=" 74 <?php 75 printf( 76 /* translators: %s: User's display name */ 77 esc_attr__( "%s's Engagements", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) 78 ); 79 ?>"> 80 <?php esc_html_e( 'Engagements', 'bbpress' ); ?> 81 </a> 50 82 </span> 51 83 </li> … … 55 87 <li class="<?php if ( bbp_is_favorites() ) : ?>current<?php endif; ?>"> 56 88 <span class="bbp-user-favorites-link"> 57 <a href="<?php bbp_favorites_permalink(); ?>" title="<?php printf( esc_attr__( "%s's Favorites", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Favorites', 'bbpress' ); ?></a> 89 <a href="<?php bbp_favorites_permalink(); ?>" title=" 90 <?php 91 printf( 92 /* translators: %s: User's display name */ 93 esc_attr__( "%s's Favorites", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) 94 ); 95 ?>"> 96 <?php esc_html_e( 'Favorites', 'bbpress' ); ?></a> 58 97 </span> 59 98 </li> … … 65 104 <li class="<?php if ( bbp_is_subscriptions() ) : ?>current<?php endif; ?>"> 66 105 <span class="bbp-user-subscriptions-link"> 67 <a href="<?php bbp_subscriptions_permalink(); ?>" title="<?php printf( esc_attr__( "%s's Subscriptions", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Subscriptions', 'bbpress' ); ?></a> 106 <a href="<?php bbp_subscriptions_permalink(); ?>" title=" 107 <?php 108 printf( 109 /* translators: %s: User's display name */ 110 esc_attr__( "%s's Subscriptions", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) 111 ); 112 ?>"> 113 <?php esc_html_e( 'Subscriptions', 'bbpress' ); ?> 114 </a> 68 115 </span> 69 116 </li> … … 72 119 <li class="<?php if ( bbp_is_single_user_edit() ) : ?>current<?php endif; ?>"> 73 120 <span class="bbp-user-edit-link"> 74 <a href="<?php bbp_user_profile_edit_url(); ?>" title="<?php printf( esc_attr__( "Edit %s's Profile", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); ?>"><?php esc_html_e( 'Edit', 'bbpress' ); ?></a> 121 <a href="<?php bbp_user_profile_edit_url(); ?>" title=" 122 <?php 123 printf( 124 /* translators: %s: User's display name */ 125 esc_attr__( "Edit %s's Profile", 'bbpress' ), bbp_get_displayed_user_field( 'display_name' ) ); 126 ?>"> 127 <?php esc_html_e( 'Edit', 'bbpress' ); ?> 128 </a> 75 129 </span> 76 130 </li> -
trunk/src/templates/default/bbpress/user-profile.php
r7146 r7360 17 17 <div class="bbp-user-section"> 18 18 <h3><?php esc_html_e( 'Profile', 'bbpress' ); ?></h3> 19 <p class="bbp-user-forum-role"><?php printf( esc_html__( 'Registered: %s', 'bbpress' ), bbp_get_time_since( bbp_get_displayed_user_field( 'user_registered' ) ) ); ?></p> 19 20 <p class="bbp-user-forum-role"> 21 <?php 22 printf( 23 /* translators: %s: Registration date in "time ago" format */ 24 esc_html__( 'Registered: %s', 'bbpress' ), 25 bbp_get_time_since( bbp_get_displayed_user_field( 'user_registered' ) ) 26 ); 27 ?> 28 </p> 20 29 21 30 <?php if ( bbp_get_displayed_user_field( 'description' ) ) : ?> 22 23 <p class="bbp-user-description"><?php echo bbp_rel_nofollow( bbp_get_displayed_user_field( 'description' ) ); ?></p>24 31 <p class="bbp-user-description"> 32 <?php echo bbp_rel_nofollow( bbp_get_displayed_user_field( 'description' ) ); ?> 33 </p> 25 34 <?php endif; ?> 26 35 27 36 <?php if ( bbp_get_displayed_user_field( 'user_url' ) ) : ?> 28 29 <p class="bbp-user-website"><?php printf( esc_html__( 'Website: %s', 'bbpress' ), bbp_rel_nofollow( bbp_make_clickable( bbp_get_displayed_user_field( 'user_url' ) ) ) ); ?></p> 30 37 <p class="bbp-user-website"> 38 <?php 39 printf( 40 /* translators: %s: User's website URL */ 41 esc_html__( 'Website: %s', 'bbpress' ), 42 bbp_rel_nofollow( bbp_make_clickable( bbp_get_displayed_user_field( 'user_url' ) ) ) 43 ); 44 ?> 45 </p> 31 46 <?php endif; ?> 32 47 … … 35 50 36 51 <?php if ( bbp_get_user_last_posted() ) : ?> 37 38 <p class="bbp-user-last-activity"><?php printf( esc_html__( 'Last Activity: %s', 'bbpress' ), bbp_get_time_since( bbp_get_user_last_posted(), false, true ) ); ?></p> 39 52 <p class="bbp-user-last-activity"> 53 <?php 54 printf( 55 /* translators: %s: Last activity time in "time ago" format */ 56 esc_html__( 'Last Activity: %s', 'bbpress' ), 57 bbp_get_time_since( bbp_get_user_last_posted(), false, true ) 58 ); 59 ?> 60 </p> 40 61 <?php endif; ?> 41 62 42 <p class="bbp-user-topic-count"><?php printf( esc_html__( 'Topics Started: %s', 'bbpress' ), bbp_get_user_topic_count() ); ?></p> 43 <p class="bbp-user-reply-count"><?php printf( esc_html__( 'Replies Created: %s', 'bbpress' ), bbp_get_user_reply_count() ); ?></p> 44 <p class="bbp-user-forum-role"><?php printf( esc_html__( 'Forum Role: %s', 'bbpress' ), bbp_get_user_display_role() ); ?></p> 63 <p class="bbp-user-topic-count"> 64 <?php 65 printf( 66 /* translators: %s: Number of topics */ 67 esc_html__( 'Topics Started: %s', 'bbpress' ), 68 bbp_get_user_topic_count() 69 ); 70 ?> 71 </p> 72 <p class="bbp-user-reply-count"> 73 <?php 74 printf( 75 /* translators: %s: Number of replies */ 76 esc_html__( 'Replies Created: %s', 'bbpress' ), 77 bbp_get_user_reply_count() 78 ); 79 ?> 80 </p> 81 <p class="bbp-user-forum-role"> 82 <?php 83 printf( 84 /* translators: %s: User's forum role */ 85 esc_html__( 'Forum Role: %s', 'bbpress' ), 86 bbp_get_user_display_role() 87 ); 88 ?> 89 </p> 45 90 </div> 46 91 </div><!-- #bbp-author-topics-started --> -
trunk/src/templates/default/extras/taxonomy-topic-tag-edit.php
r6371 r7360 15 15 16 16 <div id="topic-tag" class="bbp-topic-tag"> 17 <h1 class="entry-title"><?php printf( esc_html__( 'Topic Tag: %s', 'bbpress' ), '<span>' . bbp_get_topic_tag_name() . '</span>' ); ?></h1> 17 18 <h1 class="entry-title"> 19 <?php 20 printf( 21 /* translators: %s: Topic current tag name wrapped in span tags */ 22 esc_html__( 'Topic Tag: %s', 'bbpress' ), '<span>' . bbp_get_topic_tag_name() . '</span>' 23 ); 24 ?> 25 </h1> 18 26 19 27 <div class="entry-content"> -
trunk/src/templates/default/extras/taxonomy-topic-tag.php
r6371 r7360 15 15 16 16 <div id="topic-tag" class="bbp-topic-tag"> 17 <h1 class="entry-title"><?php printf( esc_html__( 'Topic Tag: %s', 'bbpress' ), '<span>' . bbp_get_topic_tag_name() . '</span>' ); ?></h1> 17 <h1 class="entry-title"> 18 <?php 19 printf( 20 /* translators: %s - topic tag name */ 21 esc_html__( 'Topic Tag: %s', 'bbpress' ), 22 '<span>' . bbp_get_topic_tag_name() . '</span>' 23 ); 24 ?> 25 </h1> 18 26 <div class="entry-content"> 19 27
Note: See TracChangeset
for help on using the changeset viewer.