| @@ -9,38 +9,120 @@ | ||
| 9 | 9 | |
| 10 | 10 | /** Dashboard *****************************************************************/ |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | + * Filter the Dashboard "at a glance" items and append bbPress elements to it. | |
| 14 | + * | |
| 15 | + * @since 2.6.0 bbPress (r5268) | |
| 16 | + * | |
| 17 | + * @param array $elements | |
| 18 | + * @return array | |
| 19 | + */ | |
| 20 | +function bbp_filter_dashboard_glance_items( $elements = array() ) { | |
| 21 | + | |
| 22 | + // Bail if user cannot spectate | |
| 23 | + if ( ! current_user_can( 'spectate' ) ) { | |
| 24 | + return $elements; | |
| 25 | + } | |
| 26 | + | |
| 27 | + // Get the statistics | |
| 28 | + $r = bbp_get_statistics( | |
| 29 | + array( | |
| 30 | + 'count_pending_topics' => false, | |
| 31 | + 'count_private_topics' => false, | |
| 32 | + 'count_spammed_topics' => false, | |
| 33 | + 'count_trashed_topics' => false, | |
| 34 | + 'count_pending_replies' => false, | |
| 35 | + 'count_private_replies' => false, | |
| 36 | + 'count_spammed_replies' => false, | |
| 37 | + 'count_trashed_replies' => false, | |
| 38 | + 'count_empty_tags' => false | |
| 39 | + ) | |
| 40 | + ); | |
| 41 | + | |
| 42 | + // Users | |
| 43 | + if ( isset( $r['user_count'] ) ) { | |
| 44 | + $link = admin_url( 'users.php' ); | |
| 45 | + /* translators: %s: Number of users */ | |
| 46 | + $text = sprintf( _n( '%s User', '%s Users', $r['user_count_int'], 'bbpress' ), $r['user_count'] ); | |
| 47 | + $elements[] = current_user_can( 'edit_users' ) | |
| 48 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-users">' . esc_html( $text ) . '</a>' | |
| 49 | + : esc_html( $text ); | |
| 50 | + } | |
| 51 | + | |
| 52 | + // Forums | |
| 53 | + if ( isset( $r['forum_count'] ) ) { | |
| 54 | + $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), admin_url( 'edit.php' ) ); | |
| 55 | + /* translators: %s: Number of forums */ | |
| 56 | + $text = sprintf( _n( '%s Forum', '%s Forums', $r['forum_count_int'], 'bbpress' ), $r['forum_count'] ); | |
| 57 | + $elements[] = current_user_can( 'publish_forums' ) | |
| 58 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-forums">' . esc_html( $text ) . '</a>' | |
| 59 | + : esc_html( $text ); | |
| 60 | + } | |
| 61 | + | |
| 62 | + // Topics | |
| 63 | + if ( isset( $r['topic_count'] ) ) { | |
| 64 | + $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); | |
| 65 | + /* translators: %s: Number of topics */ | |
| 66 | + $text = sprintf( _n( '%s Topic', '%s Topics', $r['topic_count_int'], 'bbpress' ), $r['topic_count'] ); | |
| 67 | + $elements[] = current_user_can( 'publish_topics' ) | |
| 68 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-topics">' . esc_html( $text ) . '</a>' | |
| 69 | + : esc_html( $text ); | |
| 70 | + } | |
| 71 | + | |
| 72 | + // Replies | |
| 73 | + if ( isset( $r['reply_count'] ) ) { | |
| 74 | + $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); | |
| 75 | + /* translators: %s: Number of replies */ | |
| 76 | + $text = sprintf( _n( '%s Reply', '%s Replies', $r['reply_count_int'], 'bbpress' ), $r['reply_count'] ); | |
| 77 | + $elements[] = current_user_can( 'publish_replies' ) | |
| 78 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-replies">' . esc_html( $text ) . '</a>' | |
| 79 | + : esc_html( $text ); | |
| 80 | + } | |
| 81 | + | |
| 82 | + // Topic Tags | |
| 83 | + if ( bbp_allow_topic_tags() && isset( $r['topic_tag_count'] ) ) { | |
| 84 | + $args = array( | |
| 85 | + 'taxonomy' => bbp_get_topic_tag_tax_id(), | |
| 86 | + 'post_type' => bbp_get_topic_post_type() | |
| 87 | + ); | |
| 88 | + $link = add_query_arg( $args, admin_url( 'edit-tags.php' ) ); | |
| 89 | + /* translators: %s: Number of topic tags */ | |
| 90 | + $text = sprintf( _n( '%s Topic Tag', '%s Topic Tags', $r['topic_tag_count_int'], 'bbpress' ), $r['topic_tag_count'] ); | |
| 91 | + | |
| 92 | + $elements[] = current_user_can( 'manage_topic_tags' ) | |
| 93 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-topic-tags">' . esc_html( $text ) . '</a>' | |
| 94 | + : esc_html( $text ); | |
| 95 | + } | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * Filters the "at a glance" dashboard items. | |
| 99 | + * | |
| 100 | + * @since 2.6.0 | |
| 101 | + * | |
| 102 | + * @param array $elements The existing "at a glance" dashboard items. | |
| 103 | + * @param array $r The statistics array. | |
| 104 | + */ | |
| 105 | + return (array) apply_filters( 'bbp_dashboard_at_a_glance', $elements, $r ); | |
| 106 | +} | |
| 107 | + | |
| 108 | +/** | |
| 13 | 109 | * bbPress Dashboard Right Now Widget |
| 14 | 110 | * |
| 15 | 111 | * Adds a dashboard widget with forum statistics |
| 16 | 112 | * |
| 17 | - * @since bbPress (r2770) | |
| 113 | + * @since 2.0.0 bbPress (r2770) | |
| 18 | 114 | * |
| 19 | - * @uses bbp_get_version() To get the current bbPress version | |
| 20 | - * @uses bbp_get_statistics() To get the forum statistics | |
| 21 | - * @uses current_user_can() To check if the user is capable of doing things | |
| 22 | - * @uses bbp_get_forum_post_type() To get the forum post type | |
| 23 | - * @uses bbp_get_topic_post_type() To get the topic post type | |
| 24 | - * @uses bbp_get_reply_post_type() To get the reply post type | |
| 25 | - * @uses get_admin_url() To get the administration url | |
| 26 | - * @uses add_query_arg() To add custom args to the url | |
| 27 | - * @uses do_action() Calls 'bbp_dashboard_widget_right_now_content_table_end' | |
| 28 | - * below the content table | |
| 29 | - * @uses do_action() Calls 'bbp_dashboard_widget_right_now_table_end' | |
| 30 | - * below the discussion table | |
| 31 | - * @uses do_action() Calls 'bbp_dashboard_widget_right_now_discussion_table_end' | |
| 32 | - * below the discussion table | |
| 33 | - * @uses do_action() Calls 'bbp_dashboard_widget_right_now_end' below the widget | |
| 115 | + * @deprecated 2.6.0 bbPress (r5268) | |
| 34 | 116 | */ |
| 35 | 117 | function bbp_dashboard_widget_right_now() { |
| 36 | 118 | |
| 37 | - // Get the statistics and extract them | |
| 38 | - extract( bbp_get_statistics(), EXTR_SKIP ); ?> | |
| 119 | + // Get the statistics | |
| 120 | + $r = bbp_get_statistics(); ?> | |
| 39 | 121 | |
| 40 | 122 | <div class="table table_content"> |
| 41 | 123 | |
| 42 | - <p class="sub"><?php _e( 'Discussion', 'bbpress' ); ?></p> | |
| 124 | + <p class="sub"><?php esc_html_e( 'Discussion', 'bbpress' ); ?></p> | |
| 43 | 125 | |
| 44 | 126 | <table> |
| 45 | 127 | |
| 46 | 128 | <tr class="first"> |
| @@ -45,14 +127,14 @@ | ||
| 45 | 127 | |
| 46 | 128 | <tr class="first"> |
| 47 | 129 | |
| 48 | 130 | <?php |
| 49 | - $num = $forum_count; | |
| 50 | - $text = _n( 'Forum', 'Forums', $forum_count, 'bbpress' ); | |
| 131 | + $num = $r['forum_count']; | |
| 132 | + $text = _n( 'Forum', 'Forums', $r['forum_count_int'], 'bbpress' ); | |
| 51 | 133 | if ( current_user_can( 'publish_forums' ) ) { |
| 52 | - $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 53 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 54 | - $text = '<a href="' . $link . '">' . $text . '</a>'; | |
| 134 | + $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), admin_url( 'edit.php' ) ); | |
| 135 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 136 | + $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 55 | 137 | } |
| 56 | 138 | ?> |
| 57 | 139 | |
| 58 | 140 | <td class="first b b-forums"><?php echo $num; ?></td> |
| @@ -62,14 +144,14 @@ | ||
| 62 | 144 | |
| 63 | 145 | <tr> |
| 64 | 146 | |
| 65 | 147 | <?php |
| 66 | - $num = $topic_count; | |
| 67 | - $text = _n( 'Topic', 'Topics', $topic_count, 'bbpress' ); | |
| 148 | + $num = $r['topic_count']; | |
| 149 | + $text = _n( 'Topic', 'Topics', $r['topic_count_int'], 'bbpress' ); | |
| 68 | 150 | if ( current_user_can( 'publish_topics' ) ) { |
| 69 | - $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 70 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 71 | - $text = '<a href="' . $link . '">' . $text . '</a>'; | |
| 151 | + $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); | |
| 152 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 153 | + $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 72 | 154 | } |
| 73 | 155 | ?> |
| 74 | 156 | |
| 75 | 157 | <td class="first b b-topics"><?php echo $num; ?></td> |
| @@ -79,14 +161,14 @@ | ||
| 79 | 161 | |
| 80 | 162 | <tr> |
| 81 | 163 | |
| 82 | 164 | <?php |
| 83 | - $num = $reply_count; | |
| 84 | - $text = _n( 'Reply', 'Replies', $reply_count, 'bbpress' ); | |
| 165 | + $num = $r['reply_count']; | |
| 166 | + $text = _n( 'Reply', 'Replies', $r['reply_count_int'], 'bbpress' ); | |
| 85 | 167 | if ( current_user_can( 'publish_replies' ) ) { |
| 86 | - $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 87 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 88 | - $text = '<a href="' . $link . '">' . $text . '</a>'; | |
| 168 | + $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); | |
| 169 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 170 | + $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 89 | 171 | } |
| 90 | 172 | ?> |
| 91 | 173 | |
| 92 | 174 | <td class="first b b-replies"><?php echo $num; ?></td> |
| @@ -98,14 +180,18 @@ | ||
| 98 | 180 | |
| 99 | 181 | <tr> |
| 100 | 182 | |
| 101 | 183 | <?php |
| 102 | - $num = $topic_tag_count; | |
| 103 | - $text = _n( 'Topic Tag', 'Topic Tags', $topic_tag_count, 'bbpress' ); | |
| 184 | + $num = $r['topic_tag_count']; | |
| 185 | + $text = _n( 'Topic Tag', 'Topic Tags', $r['topic_tag_count_int'], 'bbpress' ); | |
| 104 | 186 | if ( current_user_can( 'manage_topic_tags' ) ) { |
| 105 | - $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) ); | |
| 106 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 107 | - $text = '<a href="' . $link . '">' . $text . '</a>'; | |
| 187 | + $args = array( | |
| 188 | + 'taxonomy' => bbp_get_topic_tag_tax_id(), | |
| 189 | + 'post_type' => bbp_get_topic_post_type() | |
| 190 | + ); | |
| 191 | + $link = add_query_arg( $args, admin_url( 'edit-tags.php' ) ); | |
| 192 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 193 | + $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 108 | 194 | } |
| 109 | 195 | ?> |
| 110 | 196 | |
| 111 | 197 | <td class="first b b-topic_tags"><span class="total-count"><?php echo $num; ?></span></td> |
| @@ -123,9 +209,9 @@ | ||
| 123 | 209 | |
| 124 | 210 | |
| 125 | 211 | <div class="table table_discussion"> |
| 126 | 212 | |
| 127 | - <p class="sub"><?php _e( 'Users & Moderation', 'bbpress' ); ?></p> | |
| 213 | + <p class="sub"><?php esc_html_e( 'Users & Moderation', 'bbpress' ); ?></p> | |
| 128 | 214 | |
| 129 | 215 | <table> |
| 130 | 216 | |
| 131 | 217 | <tr class="first"> |
| @@ -130,12 +216,12 @@ | ||
| 130 | 216 | |
| 131 | 217 | <tr class="first"> |
| 132 | 218 | |
| 133 | 219 | <?php |
| 134 | - $num = $user_count; | |
| 135 | - $text = _n( 'User', 'Users', $user_count, 'bbpress' ); | |
| 220 | + $num = $r['user_count']; | |
| 221 | + $text = _n( 'User', 'Users', $r['user_count_int'], 'bbpress' ); | |
| 136 | 222 | if ( current_user_can( 'edit_users' ) ) { |
| 137 | - $link = get_admin_url( null, 'users.php' ); | |
| 223 | + $link = admin_url( 'users.php' ); | |
| 138 | 224 | $num = '<a href="' . $link . '">' . $num . '</a>'; |
| 139 | 225 | $text = '<a href="' . $link . '">' . $text . '</a>'; |
| 140 | 226 | } |
| 141 | 227 | ?> |
| @@ -144,21 +230,21 @@ | ||
| 144 | 230 | <td class="last t users"><?php echo $text; ?></td> |
| 145 | 231 | |
| 146 | 232 | </tr> |
| 147 | 233 | |
| 148 | - <?php if ( isset( $topic_count_hidden ) ) : ?> | |
| 234 | + <?php if ( isset( $r['topic_count_hidden'] ) ) : ?> | |
| 149 | 235 | |
| 150 | 236 | <tr> |
| 151 | 237 | |
| 152 | 238 | <?php |
| 153 | - $num = $topic_count_hidden; | |
| 154 | - $text = _n( 'Hidden Topic', 'Hidden Topics', $topic_count_hidden, 'bbpress' ); | |
| 155 | - $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 156 | - if ( '0' != $num ) { | |
| 239 | + $num = $r['topic_count_hidden']; | |
| 240 | + $text = _n( 'Hidden Topic', 'Hidden Topics', $r['topic_count_hidden_int'], 'bbpress' ); | |
| 241 | + $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); | |
| 242 | + if ( '0' !== $num ) { | |
| 157 | 243 | $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); |
| 158 | 244 | } |
| 159 | - $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $num . '</a>'; | |
| 160 | - $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $text . '</a>'; | |
| 245 | + $num = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_topic_title'] ) . '">' . $num . '</a>'; | |
| 246 | + $text = '<a class="waiting" href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_topic_title'] ) . '">' . $text . '</a>'; | |
| 161 | 247 | ?> |
| 162 | 248 | |
| 163 | 249 | <td class="b b-hidden-topics"><?php echo $num; ?></td> |
| 164 | 250 | <td class="last t hidden-replies"><?php echo $text; ?></td> |
| @@ -166,21 +252,21 @@ | ||
| 166 | 252 | </tr> |
| 167 | 253 | |
| 168 | 254 | <?php endif; ?> |
| 169 | 255 | |
| 170 | - <?php if ( isset( $reply_count_hidden ) ) : ?> | |
| 256 | + <?php if ( isset( $r['reply_count_hidden'] ) ) : ?> | |
| 171 | 257 | |
| 172 | 258 | <tr> |
| 173 | 259 | |
| 174 | 260 | <?php |
| 175 | - $num = $reply_count_hidden; | |
| 176 | - $text = _n( 'Hidden Reply', 'Hidden Replies', $reply_count_hidden, 'bbpress' ); | |
| 177 | - $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 178 | - if ( '0' != $num ) { | |
| 261 | + $num = $r['reply_count_hidden']; | |
| 262 | + $text = _n( 'Hidden Reply', 'Hidden Replies', $r['reply_count_hidden_int'], 'bbpress' ); | |
| 263 | + $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); | |
| 264 | + if ( '0' !== $num ) { | |
| 179 | 265 | $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); |
| 180 | 266 | } |
| 181 | - $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $num . '</a>'; | |
| 182 | - $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $text . '</a>'; | |
| 267 | + $num = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_reply_title'] ) . '">' . $num . '</a>'; | |
| 268 | + $text = '<a class="waiting" href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_reply_title'] ) . '">' . $text . '</a>'; | |
| 183 | 269 | ?> |
| 184 | 270 | |
| 185 | 271 | <td class="b b-hidden-replies"><?php echo $num; ?></td> |
| 186 | 272 | <td class="last t hidden-replies"><?php echo $text; ?></td> |
| @@ -188,18 +274,22 @@ | ||
| 188 | 274 | </tr> |
| 189 | 275 | |
| 190 | 276 | <?php endif; ?> |
| 191 | 277 | |
| 192 | - <?php if ( bbp_allow_topic_tags() && isset( $empty_topic_tag_count ) ) : ?> | |
| 278 | + <?php if ( bbp_allow_topic_tags() && isset( $r['empty_topic_tag_count'] ) ) : ?> | |
| 193 | 279 | |
| 194 | 280 | <tr> |
| 195 | 281 | |
| 196 | 282 | <?php |
| 197 | - $num = $empty_topic_tag_count; | |
| 198 | - $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $empty_topic_tag_count, 'bbpress' ); | |
| 199 | - $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) ); | |
| 200 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 201 | - $text = '<a class="waiting" href="' . $link . '">' . $text . '</a>'; | |
| 283 | + $num = $r['empty_topic_tag_count']; | |
| 284 | + $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $r['empty_topic_tag_count_int'], 'bbpress' ); | |
| 285 | + $args = array( | |
| 286 | + 'taxonomy' => bbp_get_topic_tag_tax_id(), | |
| 287 | + 'post_type' => bbp_get_topic_post_type() | |
| 288 | + ); | |
| 289 | + $link = add_query_arg( $args, admin_url( 'edit-tags.php' ) ); | |
| 290 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 291 | + $text = '<a class="waiting" href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 202 | 292 | ?> |
| 203 | 293 | |
| 204 | 294 | <td class="b b-hidden-topic-tags"><?php echo $num; ?></td> |
| 205 | 295 | <td class="last t hidden-topic-tags"><?php echo $text; ?></td> |
| @@ -218,9 +308,15 @@ | ||
| 218 | 308 | |
| 219 | 309 | <div class="versions"> |
| 220 | 310 | |
| 221 | 311 | <span id="wp-version-message"> |
| 222 | - <?php printf( __( 'You are using <span class="b">bbPress %s</span>.', 'bbpress' ), bbp_get_version() ); ?> | |
| 312 | + <?php | |
| 313 | + printf( | |
| 314 | + /* translators: %s: bbPress version */ | |
| 315 | + __( 'You are using <span class="b">bbPress %s</span>.', 'bbpress' ), | |
| 316 | + bbp_get_version() | |
| 317 | + ); | |
| 318 | + ?> | |
| 223 | 319 | </span> |
| 224 | 320 | |
| 225 | 321 | </div> |
| 226 | 322 | |
| @@ -233,24 +329,17 @@ | ||
| 233 | 329 | |
| 234 | 330 | /** Forums ********************************************************************/ |
| 235 | 331 | |
| 236 | 332 | /** |
| 237 | - * Forum metabox | |
| 333 | + * Forum meta-box | |
| 238 | 334 | * |
| 239 | - * The metabox that holds all of the additional forum information | |
| 335 | + * The meta-box that holds all of the additional forum information | |
| 240 | 336 | * |
| 241 | - * @since bbPress (r2744) | |
| 242 | - * | |
| 243 | - * @uses bbp_is_forum_closed() To check if a forum is closed or not | |
| 244 | - * @uses bbp_is_forum_category() To check if a forum is a category or not | |
| 245 | - * @uses bbp_is_forum_private() To check if a forum is private or not | |
| 246 | - * @uses bbp_dropdown() To show a dropdown of the forums for forum parent | |
| 247 | - * @uses do_action() Calls 'bbp_forum_metabox' | |
| 337 | + * @since 2.0.0 bbPress (r2744) | |
| 248 | 338 | */ |
| 249 | -function bbp_forum_metabox() { | |
| 339 | +function bbp_forum_metabox( $post ) { | |
| 250 | 340 | |
| 251 | 341 | // Post ID |
| 252 | - $post_id = get_the_ID(); | |
| 253 | 342 | $post_parent = bbp_get_global_post_field( 'post_parent', 'raw' ); |
| 254 | 343 | $menu_order = bbp_get_global_post_field( 'menu_order', 'edit' ); |
| 255 | 344 | |
| 256 | 345 | /** Type ******************************************************************/ |
| @@ -257,11 +346,11 @@ | ||
| 257 | 346 | |
| 258 | 347 | ?> |
| 259 | 348 | |
| 260 | 349 | <p> |
| 261 | - <strong class="label"><?php _e( 'Type:', 'bbpress' ); ?></strong> | |
| 262 | - <label class="screen-reader-text" for="bbp_forum_type_select"><?php _e( 'Type:', 'bbpress' ) ?></label> | |
| 263 | - <?php bbp_form_forum_type_dropdown( $post_id ); ?> | |
| 350 | + <strong class="label"><?php esc_html_e( 'Type:', 'bbpress' ); ?></strong> | |
| 351 | + <label class="screen-reader-text" for="bbp_forum_type_select"><?php esc_html_e( 'Type:', 'bbpress' ); ?></label> | |
| 352 | + <?php bbp_form_forum_type_dropdown( array( 'forum_id' => $post->ID ) ); ?> | |
| 264 | 353 | </p> |
| 265 | 354 | |
| 266 | 355 | <?php |
| 267 | 356 | |
| @@ -269,11 +358,11 @@ | ||
| 269 | 358 | |
| 270 | 359 | ?> |
| 271 | 360 | |
| 272 | 361 | <p> |
| 273 | - <strong class="label"><?php _e( 'Status:', 'bbpress' ); ?></strong> | |
| 274 | - <label class="screen-reader-text" for="bbp_forum_status_select"><?php _e( 'Status:', 'bbpress' ) ?></label> | |
| 275 | - <?php bbp_form_forum_status_dropdown( $post_id ); ?> | |
| 362 | + <strong class="label"><?php esc_html_e( 'Status:', 'bbpress' ); ?></strong> | |
| 363 | + <label class="screen-reader-text" for="bbp_forum_status_select"><?php esc_html_e( 'Status:', 'bbpress' ); ?></label> | |
| 364 | + <?php bbp_form_forum_status_dropdown( array( 'forum_id' => $post->ID ) ); ?> | |
| 276 | 365 | </p> |
| 277 | 366 | |
| 278 | 367 | <?php |
| 279 | 368 | |
| @@ -281,11 +370,11 @@ | ||
| 281 | 370 | |
| 282 | 371 | ?> |
| 283 | 372 | |
| 284 | 373 | <p> |
| 285 | - <strong class="label"><?php _e( 'Visibility:', 'bbpress' ); ?></strong> | |
| 286 | - <label class="screen-reader-text" for="bbp_forum_visibility_select"><?php _e( 'Visibility:', 'bbpress' ) ?></label> | |
| 287 | - <?php bbp_form_forum_visibility_dropdown( $post_id ); ?> | |
| 374 | + <strong class="label"><?php esc_html_e( 'Visibility:', 'bbpress' ); ?></strong> | |
| 375 | + <label class="screen-reader-text" for="bbp_forum_visibility_select"><?php esc_html_e( 'Visibility:', 'bbpress' ); ?></label> | |
| 376 | + <?php bbp_form_forum_visibility_dropdown( array( 'forum_id' => $post->ID ) ); ?> | |
| 288 | 377 | </p> |
| 289 | 378 | |
| 290 | 379 | <hr /> |
| 291 | 380 | |
| @@ -295,201 +384,510 @@ | ||
| 295 | 384 | |
| 296 | 385 | ?> |
| 297 | 386 | |
| 298 | 387 | <p> |
| 299 | - <strong class="label"><?php _e( 'Parent:', 'bbpress' ); ?></strong> | |
| 300 | - <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum Parent', 'bbpress' ); ?></label> | |
| 301 | - <?php bbp_dropdown( array( | |
| 302 | - 'post_type' => bbp_get_forum_post_type(), | |
| 303 | - 'selected' => $post_parent, | |
| 304 | - 'child_of' => '0', | |
| 305 | - 'numberposts' => -1, | |
| 306 | - 'orderby' => 'title', | |
| 307 | - 'order' => 'ASC', | |
| 308 | - 'walker' => '', | |
| 309 | - 'exclude' => $post_id, | |
| 388 | + <strong class="label"><?php esc_html_e( 'Parent:', 'bbpress' ); ?></strong> | |
| 389 | + <label class="screen-reader-text" for="parent_id"><?php esc_html_e( 'Forum Parent', 'bbpress' ); ?></label> | |
| 390 | + <?php | |
| 391 | + bbp_dropdown( | |
| 392 | + array( | |
| 393 | + 'post_type' => bbp_get_forum_post_type(), | |
| 394 | + 'selected' => $post_parent, | |
| 395 | + 'numberposts' => -1, | |
| 396 | + 'orderby' => 'title', | |
| 397 | + 'order' => 'ASC', | |
| 398 | + 'walker' => '', | |
| 399 | + 'exclude' => $post->ID, | |
| 310 | 400 | |
| 311 | - // Output-related | |
| 312 | - 'select_id' => 'parent_id', | |
| 313 | - 'tab' => bbp_get_tab_index(), | |
| 314 | - 'options_only' => false, | |
| 315 | - 'show_none' => __( '— No parent —', 'bbpress' ), | |
| 316 | - 'none_found' => false, | |
| 317 | - 'disable_categories' => false, | |
| 318 | - 'disabled' => '' | |
| 319 | - ) ); ?> | |
| 401 | + // Output-related | |
| 402 | + 'select_id' => 'parent_id', | |
| 403 | + 'options_only' => false, | |
| 404 | + 'show_none' => esc_html__( '— No parent —', 'bbpress' ), | |
| 405 | + 'disable_categories' => false, | |
| 406 | + 'disabled' => '' | |
| 407 | + ) | |
| 408 | + ); | |
| 409 | + ?> | |
| 320 | 410 | </p> |
| 321 | 411 | |
| 322 | 412 | <p> |
| 323 | - <strong class="label"><?php _e( 'Order:', 'bbpress' ); ?></strong> | |
| 324 | - <label class="screen-reader-text" for="menu_order"><?php _e( 'Forum Order', 'bbpress' ); ?></label> | |
| 413 | + <strong class="label"><?php esc_html_e( 'Order:', 'bbpress' ); ?></strong> | |
| 414 | + <label class="screen-reader-text" for="menu_order"><?php esc_html_e( 'Forum Order', 'bbpress' ); ?></label> | |
| 325 | 415 | <input name="menu_order" type="number" step="1" size="4" id="menu_order" value="<?php echo esc_attr( $menu_order ); ?>" /> |
| 326 | 416 | </p> |
| 327 | 417 | |
| 418 | + <input name="ping_status" type="hidden" id="ping_status" value="open" /> | |
| 419 | + | |
| 328 | 420 | <?php |
| 329 | 421 | wp_nonce_field( 'bbp_forum_metabox_save', 'bbp_forum_metabox' ); |
| 330 | - do_action( 'bbp_forum_metabox', $post_id ); | |
| 422 | + do_action( 'bbp_forum_metabox', $post ); | |
| 331 | 423 | } |
| 332 | 424 | |
| 333 | 425 | /** Topics ********************************************************************/ |
| 334 | 426 | |
| 335 | 427 | /** |
| 336 | - * Topic metabox | |
| 428 | + * Topic meta-box | |
| 337 | 429 | * |
| 338 | - * The metabox that holds all of the additional topic information | |
| 430 | + * The meta-box that holds all of the additional topic information | |
| 339 | 431 | * |
| 340 | - * @since bbPress (r2464) | |
| 341 | - * | |
| 342 | - * @uses bbp_get_topic_forum_id() To get the topic forum id | |
| 343 | - * @uses do_action() Calls 'bbp_topic_metabox' | |
| 432 | + * @since 2.0.0 bbPress (r2464) | |
| 344 | 433 | */ |
| 345 | -function bbp_topic_metabox() { | |
| 434 | +function bbp_topic_metabox( $post ) { | |
| 346 | 435 | |
| 347 | - // Post ID | |
| 348 | - $post_id = get_the_ID(); ?> | |
| 436 | + /** Type ******************************************************************/ | |
| 349 | 437 | |
| 438 | + ?> | |
| 439 | + | |
| 350 | 440 | <p> |
| 351 | - <strong class="label"><?php _e( 'Type:', 'bbpress' ); ?></strong> | |
| 352 | - <label class="screen-reader-text" for="bbp_stick_topic"><?php _e( 'Topic Type', 'bbpress' ); ?></label> | |
| 353 | - <?php bbp_topic_type_select( array( 'topic_id' => $post_id ) ); ?> | |
| 441 | + <strong class="label"><?php esc_html_e( 'Type:', 'bbpress' ); ?></strong> | |
| 442 | + <label class="screen-reader-text" for="bbp_stick_topic"><?php esc_html_e( 'Topic Type', 'bbpress' ); ?></label> | |
| 443 | + <?php bbp_form_topic_type_dropdown( array( 'topic_id' => $post->ID ) ); ?> | |
| 354 | 444 | </p> |
| 355 | 445 | |
| 446 | + <?php | |
| 447 | + | |
| 448 | + /** Status ****************************************************************/ | |
| 449 | + | |
| 450 | + ?> | |
| 451 | + | |
| 356 | 452 | <p> |
| 357 | - <strong class="label"><?php _e( 'Forum:', 'bbpress' ); ?></strong> | |
| 358 | - <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum', 'bbpress' ); ?></label> | |
| 359 | - <?php bbp_dropdown( array( | |
| 360 | - 'post_type' => bbp_get_forum_post_type(), | |
| 361 | - 'selected' => bbp_get_topic_forum_id( $post_id ), | |
| 362 | - 'child_of' => '0', | |
| 363 | - 'numberposts' => -1, | |
| 364 | - 'orderby' => 'title', | |
| 365 | - 'order' => 'ASC', | |
| 366 | - 'walker' => '', | |
| 367 | - 'exclude' => '', | |
| 453 | + <strong class="label"><?php esc_html_e( 'Status:', 'bbpress' ); ?></strong> | |
| 454 | + <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' === $post->post_status ) ? 'draft' : $post->post_status ); ?>" /> | |
| 455 | + <label class="screen-reader-text" for="bbp_open_close_topic"><?php esc_html_e( 'Select whether to open or close the topic.', 'bbpress' ); ?></label> | |
| 456 | + <?php bbp_form_topic_status_dropdown( | |
| 457 | + array( | |
| 458 | + 'select_id' => 'post_status', | |
| 459 | + 'topic_id' => $post->ID | |
| 460 | + ) | |
| 461 | + ); ?> | |
| 462 | + </p> | |
| 368 | 463 | |
| 369 | - // Output-related | |
| 370 | - 'select_id' => 'parent_id', | |
| 371 | - 'tab' => bbp_get_tab_index(), | |
| 372 | - 'options_only' => false, | |
| 373 | - 'show_none' => __( '— No parent —', 'bbpress' ), | |
| 374 | - 'none_found' => false, | |
| 375 | - 'disable_categories' => current_user_can( 'edit_forums' ), | |
| 376 | - 'disabled' => '' | |
| 377 | - ) ); ?> | |
| 464 | + <?php | |
| 465 | + | |
| 466 | + /** Parent *****************************************************************/ | |
| 467 | + | |
| 468 | + ?> | |
| 469 | + | |
| 470 | + <hr /> | |
| 471 | + | |
| 472 | + <p> | |
| 473 | + <strong class="label"><?php esc_html_e( 'Forum:', 'bbpress' ); ?></strong> | |
| 474 | + <label class="screen-reader-text" for="parent_id"><?php esc_html_e( 'Forum', 'bbpress' ); ?></label> | |
| 475 | + <?php | |
| 476 | + bbp_dropdown( | |
| 477 | + array( | |
| 478 | + 'post_type' => bbp_get_forum_post_type(), | |
| 479 | + 'selected' => bbp_get_topic_forum_id( $post->ID ), | |
| 480 | + 'numberposts' => -1, | |
| 481 | + 'orderby' => 'title', | |
| 482 | + 'order' => 'ASC', | |
| 483 | + 'walker' => '', | |
| 484 | + 'exclude' => '', | |
| 485 | + | |
| 486 | + // Output-related | |
| 487 | + 'select_id' => 'parent_id', | |
| 488 | + 'options_only' => false, | |
| 489 | + 'show_none' => esc_html__( '— No forum —', 'bbpress' ), | |
| 490 | + 'disable_categories' => current_user_can( 'edit_forums' ), | |
| 491 | + 'disabled' => '' | |
| 492 | + ) | |
| 493 | + ); | |
| 494 | + ?> | |
| 378 | 495 | </p> |
| 379 | 496 | |
| 497 | + <input name="ping_status" type="hidden" id="ping_status" value="open" /> | |
| 498 | + | |
| 380 | 499 | <?php |
| 381 | 500 | wp_nonce_field( 'bbp_topic_metabox_save', 'bbp_topic_metabox' ); |
| 382 | - do_action( 'bbp_topic_metabox', $post_id ); | |
| 501 | + do_action( 'bbp_topic_metabox', $post ); | |
| 383 | 502 | } |
| 384 | 503 | |
| 385 | 504 | /** Replies *******************************************************************/ |
| 386 | 505 | |
| 387 | 506 | /** |
| 388 | - * Reply metabox | |
| 507 | + * Reply meta-box | |
| 389 | 508 | * |
| 390 | - * The metabox that holds all of the additional reply information | |
| 509 | + * The meta-box that holds all of the additional reply information | |
| 391 | 510 | * |
| 392 | - * @since bbPress (r2464) | |
| 393 | - * | |
| 394 | - * @uses bbp_get_topic_post_type() To get the topic post type | |
| 395 | - * @uses do_action() Calls 'bbp_reply_metabox' | |
| 511 | + * @since 2.0.0 bbPress (r2464) | |
| 396 | 512 | */ |
| 397 | -function bbp_reply_metabox() { | |
| 513 | +function bbp_reply_metabox( $post ) { | |
| 398 | 514 | |
| 399 | - // Post ID | |
| 400 | - $post_id = get_the_ID(); | |
| 515 | + // Get some meta | |
| 516 | + $reply_topic_id = bbp_get_reply_topic_id( $post->ID ); | |
| 517 | + $reply_forum_id = bbp_get_reply_forum_id( $post->ID ); | |
| 518 | + $topic_forum_id = bbp_get_topic_forum_id( $reply_topic_id ); | |
| 401 | 519 | |
| 402 | - // Get some meta | |
| 403 | - $reply_topic_id = bbp_get_reply_topic_id( $post_id ); | |
| 404 | - $reply_forum_id = bbp_get_reply_forum_id( $post_id ); | |
| 520 | + /** Status ****************************************************************/ | |
| 405 | 521 | |
| 406 | - // Allow individual manipulation of reply forum | |
| 407 | - if ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate' ) ) : ?> | |
| 522 | + ?> | |
| 408 | 523 | |
| 524 | + <p> | |
| 525 | + <strong class="label"><?php esc_html_e( 'Status:', 'bbpress' ); ?></strong> | |
| 526 | + <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' === $post->post_status ) ? 'draft' : $post->post_status ); ?>" /> | |
| 527 | + <label class="screen-reader-text" for="post_status"><?php esc_html_e( 'Select what status to give the reply.', 'bbpress' ); ?></label> | |
| 528 | + <?php bbp_form_reply_status_dropdown( | |
| 529 | + array( | |
| 530 | + 'select_id' => 'post_status', | |
| 531 | + 'reply_id' => $post->ID | |
| 532 | + ) | |
| 533 | + ); ?> | |
| 534 | + </p> | |
| 535 | + | |
| 536 | + <hr /> | |
| 537 | + | |
| 538 | + <?php | |
| 539 | + | |
| 540 | + /** Forum *****************************************************************/ | |
| 541 | + | |
| 542 | + // Only allow individual manipulation of reply forum if there is a mismatch | |
| 543 | + if ( ( $reply_forum_id !== $topic_forum_id ) && ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate', $post->ID ) ) ) : ?> | |
| 544 | + | |
| 409 | 545 | <p> |
| 410 | - <strong class="label"><?php _e( 'Forum:', 'bbpress' ); ?></strong> | |
| 411 | - <label class="screen-reader-text" for="bbp_forum_id"><?php _e( 'Forum', 'bbpress' ); ?></label> | |
| 412 | - <?php bbp_dropdown( array( | |
| 413 | - 'post_type' => bbp_get_forum_post_type(), | |
| 414 | - 'selected' => $reply_forum_id, | |
| 415 | - 'child_of' => '0', | |
| 416 | - 'numberposts' => -1, | |
| 417 | - 'orderby' => 'title', | |
| 418 | - 'order' => 'ASC', | |
| 419 | - 'walker' => '', | |
| 420 | - 'exclude' => '', | |
| 546 | + <strong class="label"><?php esc_html_e( 'Forum:', 'bbpress' ); ?></strong> | |
| 547 | + <label class="screen-reader-text" for="bbp_forum_id"><?php esc_html_e( 'Forum', 'bbpress' ); ?></label> | |
| 548 | + <?php | |
| 549 | + bbp_dropdown( | |
| 550 | + array( | |
| 551 | + 'post_type' => bbp_get_forum_post_type(), | |
| 552 | + 'selected' => $reply_forum_id, | |
| 553 | + 'numberposts' => -1, | |
| 554 | + 'orderby' => 'title', | |
| 555 | + 'order' => 'ASC', | |
| 556 | + 'walker' => '', | |
| 557 | + 'exclude' => '', | |
| 421 | 558 | |
| 422 | - // Output-related | |
| 423 | - 'select_id' => 'bbp_forum_id', | |
| 424 | - 'tab' => bbp_get_tab_index(), | |
| 425 | - 'options_only' => false, | |
| 426 | - 'show_none' => __( '— No parent —', 'bbpress' ), | |
| 427 | - 'none_found' => false, | |
| 428 | - 'disable_categories' => current_user_can( 'edit_forums' ), | |
| 429 | - 'disabled' => '' | |
| 430 | - ) ); ?> | |
| 559 | + // Output-related | |
| 560 | + 'select_id' => 'bbp_forum_id', | |
| 561 | + 'options_only' => false, | |
| 562 | + 'show_none' => esc_html__( '— No reply —', 'bbpress' ), | |
| 563 | + 'disable_categories' => current_user_can( 'edit_forums' ), | |
| 564 | + 'disabled' => '' | |
| 565 | + ) | |
| 566 | + ); | |
| 567 | + ?> | |
| 431 | 568 | </p> |
| 432 | 569 | |
| 433 | - <?php endif; ?> | |
| 570 | + <?php endif; | |
| 434 | 571 | |
| 572 | + /** Topic *****************************************************************/ | |
| 573 | + | |
| 574 | + ?> | |
| 575 | + | |
| 435 | 576 | <p> |
| 436 | - <strong class="label"><?php _e( 'Topic:', 'bbpress' ); ?></strong> | |
| 437 | - <label class="screen-reader-text" for="parent_id"><?php _e( 'Topic', 'bbpress' ); ?></label> | |
| 438 | - <input name="parent_id" id="bbp_topic_id" type="text" value="<?php echo esc_attr( $reply_topic_id ); ?>" /> | |
| 577 | + <strong class="label"><?php esc_html_e( 'Topic:', 'bbpress' ); ?></strong> | |
| 578 | + <label class="screen-reader-text" for="parent_id"><?php esc_html_e( 'Topic', 'bbpress' ); ?></label> | |
| 579 | + <input name="parent_id" id="bbp_topic_id" type="text" value="<?php echo esc_attr( $reply_topic_id ); ?>" data-ajax-url="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_suggest_topic' ), admin_url( 'admin-ajax.php', 'relative' ) ), 'bbp_suggest_topic_nonce' ) ); ?>" /> | |
| 439 | 580 | </p> |
| 440 | 581 | |
| 441 | 582 | <?php |
| 583 | + | |
| 584 | + /** Reply To **************************************************************/ | |
| 585 | + | |
| 586 | + // Only show reply-to drop-down when editing an existing reply | |
| 587 | + if ( ! empty( $reply_topic_id ) ) : ?> | |
| 588 | + | |
| 589 | + <p> | |
| 590 | + <strong class="label"><?php esc_html_e( 'Reply To:', 'bbpress' ); ?></strong> | |
| 591 | + <label class="screen-reader-text" for="bbp_reply_to"><?php esc_html_e( 'Reply To', 'bbpress' ); ?></label> | |
| 592 | + <?php bbp_reply_to_dropdown( $post->ID ); ?> | |
| 593 | + </p> | |
| 594 | + | |
| 595 | + <?php | |
| 596 | + | |
| 597 | + endif; | |
| 598 | + | |
| 599 | + ?> | |
| 600 | + | |
| 601 | + <input name="ping_status" type="hidden" id="ping_status" value="open" /> | |
| 602 | + | |
| 603 | + <?php | |
| 442 | 604 | wp_nonce_field( 'bbp_reply_metabox_save', 'bbp_reply_metabox' ); |
| 443 | - do_action( 'bbp_reply_metabox', $post_id ); | |
| 605 | + do_action( 'bbp_reply_metabox', $post ); | |
| 444 | 606 | } |
| 445 | 607 | |
| 608 | +/** | |
| 609 | + * Output the topic replies meta-box | |
| 610 | + * | |
| 611 | + * @since 2.6.0 bbPress (r5886) | |
| 612 | + * | |
| 613 | + * @param object $topic | |
| 614 | + * | |
| 615 | + * @return void | |
| 616 | + */ | |
| 617 | +function bbp_topic_replies_metabox( $topic = false ) { | |
| 618 | + | |
| 619 | + // Bail if no topic to load replies for | |
| 620 | + if ( empty( $topic ) ) { | |
| 621 | + return; | |
| 622 | + } | |
| 623 | + | |
| 624 | + // Pull in the list table class | |
| 625 | + if ( ! class_exists( 'BBP_Topic_Replies_List_Table' ) ) { | |
| 626 | + require_once bbp_admin()->admin_dir . '/classes/class-bbp-topic-replies-list-table.php'; | |
| 627 | + } | |
| 628 | + | |
| 629 | + // Look for pagination value | |
| 630 | + $page = isset( $_REQUEST['page'] ) | |
| 631 | + ? (int) $_REQUEST['page'] | |
| 632 | + : 0; | |
| 633 | + | |
| 634 | + // Load up the list table | |
| 635 | + $replies_list_table = new BBP_Topic_Replies_List_Table(); | |
| 636 | + $replies_list_table->prepare_items( $topic->ID ); ?> | |
| 637 | + | |
| 638 | + <form id="bbp-topic-replies" method="get"> | |
| 639 | + <input type="hidden" name="page" value="<?php echo esc_attr( $page ); ?>" /> | |
| 640 | + | |
| 641 | + <?php $replies_list_table->display(); ?> | |
| 642 | + </form> | |
| 643 | + | |
| 644 | + <?php | |
| 645 | +} | |
| 646 | + | |
| 446 | 647 | /** Users *********************************************************************/ |
| 447 | 648 | |
| 448 | 649 | /** |
| 449 | - * Anonymous user information metabox | |
| 650 | + * Anonymous user information meta-box | |
| 450 | 651 | * |
| 451 | - * @since bbPress (r2828) | |
| 652 | + * @since 2.0.0 bbPress (r2828) | |
| 452 | 653 | * |
| 453 | - * @uses bbp_is_reply_anonymous() To check if reply is anonymous | |
| 454 | - * @uses bbp_is_topic_anonymous() To check if topic is anonymous | |
| 455 | - * @uses get_the_ID() To get the global post ID | |
| 456 | - * @uses get_post_meta() To get the author user information | |
| 654 | + * @param WP_Post $post The current post object | |
| 457 | 655 | */ |
| 458 | -function bbp_author_metabox() { | |
| 656 | +function bbp_author_metabox( $post ) { | |
| 459 | 657 | |
| 460 | - // Post ID | |
| 461 | - $post_id = get_the_ID(); | |
| 658 | + // Show extra bits if topic/reply is anonymous | |
| 659 | + if ( bbp_is_reply_anonymous( $post->ID ) || bbp_is_topic_anonymous( $post->ID ) ) : ?> | |
| 462 | 660 | |
| 463 | - // Show extra bits if topic/reply is anonymous | |
| 464 | - if ( bbp_is_reply_anonymous( $post_id ) || bbp_is_topic_anonymous( $post_id ) ) : ?> | |
| 661 | + <p> | |
| 662 | + <strong class="label"><?php esc_html_e( 'Name:', 'bbpress' ); ?></strong> | |
| 663 | + <label class="screen-reader-text" for="bbp_anonymous_name"><?php esc_html_e( 'Name', 'bbpress' ); ?></label> | |
| 664 | + <input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php echo esc_attr( get_post_meta( $post->ID, '_bbp_anonymous_name', true ) ); ?>" /> | |
| 665 | + </p> | |
| 465 | 666 | |
| 466 | 667 | <p> |
| 467 | - <strong class="label"><?php _e( 'Name:', 'bbpress' ); ?></strong> | |
| 468 | - <label class="screen-reader-text" for="bbp_anonymous_name"><?php _e( 'Name', 'bbpress' ); ?></label> | |
| 469 | - <input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_name', true ) ); ?>" /> | |
| 668 | + <strong class="label"><?php esc_html_e( 'Email:', 'bbpress' ); ?></strong> | |
| 669 | + <label class="screen-reader-text" for="bbp_anonymous_email"><?php esc_html_e( 'Email', 'bbpress' ); ?></label> | |
| 670 | + <input type="text" id="bbp_anonymous_email" name="bbp_anonymous_email" value="<?php echo esc_attr( get_post_meta( $post->ID, '_bbp_anonymous_email', true ) ); ?>" /> | |
| 470 | 671 | </p> |
| 471 | 672 | |
| 472 | 673 | <p> |
| 473 | - <strong class="label"><?php _e( 'Email:', 'bbpress' ); ?></strong> | |
| 474 | - <label class="screen-reader-text" for="bbp_anonymous_email"><?php _e( 'Email', 'bbpress' ); ?></label> | |
| 475 | - <input type="text" id="bbp_anonymous_email" name="bbp_anonymous_email" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_email', true ) ); ?>" /> | |
| 674 | + <strong class="label"><?php esc_html_e( 'Website:', 'bbpress' ); ?></strong> | |
| 675 | + <label class="screen-reader-text" for="bbp_anonymous_website"><?php esc_html_e( 'Website', 'bbpress' ); ?></label> | |
| 676 | + <input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php echo esc_attr( get_post_meta( $post->ID, '_bbp_anonymous_website', true ) ); ?>" /> | |
| 476 | 677 | </p> |
| 477 | 678 | |
| 679 | + <?php else : ?> | |
| 680 | + | |
| 478 | 681 | <p> |
| 479 | - <strong class="label"><?php _e( 'Website:', 'bbpress' ); ?></strong> | |
| 480 | - <label class="screen-reader-text" for="bbp_anonymous_website"><?php _e( 'Website', 'bbpress' ); ?></label> | |
| 481 | - <input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_website', true ) ); ?>" /> | |
| 682 | + <strong class="label"><?php esc_html_e( 'ID:', 'bbpress' ); ?></strong> | |
| 683 | + <label class="screen-reader-text" for="bbp_author_id"><?php esc_html_e( 'ID', 'bbpress' ); ?></label> | |
| 684 | + <input type="text" id="bbp_author_id" name="post_author_override" value="<?php echo esc_attr( bbp_get_global_post_field( 'post_author' ) ); ?>" data-ajax-url="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_suggest_user' ), admin_url( 'admin-ajax.php', 'relative' ) ), 'bbp_suggest_user_nonce' ) ); ?>" /> | |
| 482 | 685 | </p> |
| 483 | 686 | |
| 484 | 687 | <?php endif; ?> |
| 485 | 688 | |
| 486 | 689 | <p> |
| 487 | - <strong class="label"><?php _e( 'IP:', 'bbpress' ); ?></strong> | |
| 488 | - <label class="screen-reader-text" for="bbp_author_ip_address"><?php _e( 'IP Address', 'bbpress' ); ?></label> | |
| 489 | - <input type="text" id="bbp_author_ip_address" name="bbp_author_ip_address" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_author_ip', true ) ); ?>" disabled="disabled" /> | |
| 690 | + <strong class="label"><?php esc_html_e( 'IP:', 'bbpress' ); ?></strong> | |
| 691 | + <label class="screen-reader-text" for="bbp_author_ip_address"><?php esc_html_e( 'IP Address', 'bbpress' ); ?></label> | |
| 692 | + <input type="text" id="bbp_author_ip_address" name="bbp_author_ip_address" value="<?php echo esc_attr( get_post_meta( $post->ID, '_bbp_author_ip', true ) ); ?>" disabled="disabled" /> | |
| 490 | 693 | </p> |
| 491 | 694 | |
| 492 | 695 | <?php |
| 493 | 696 | |
| 494 | - do_action( 'bbp_author_metabox', $post_id ); | |
| 697 | + do_action( 'bbp_author_metabox', $post ); | |
| 698 | +} | |
| 699 | + | |
| 700 | +/** | |
| 701 | + * Moderator assignment meta-box | |
| 702 | + * | |
| 703 | + * @since 2.6.0 bbPress (r2828) | |
| 704 | + */ | |
| 705 | +function bbp_moderator_assignment_metabox( $post ) { | |
| 706 | + | |
| 707 | + // Get nicenames | |
| 708 | + $user_ids = bbp_get_moderator_ids( $post->ID ); | |
| 709 | + $user_nicenames = bbp_get_user_nicenames_from_ids( $user_ids ); | |
| 710 | + $moderators = ! empty( $user_nicenames ) | |
| 711 | + ? implode( ', ', array_map( 'esc_attr', $user_nicenames ) ) | |
| 712 | + : ''; ?> | |
| 713 | + | |
| 714 | + <label class="screen-reader-text" for="bbp_moderators"><?php esc_html_e( 'Moderators', 'bbpress' ); ?></label> | |
| 715 | + <input type="text" id="bbp_moderators" name="bbp_moderators" value="<?php echo esc_attr( $moderators ); ?>" /> | |
| 716 | + <p class="howto"><?php esc_html_e( 'Separate user-names with commas', 'bbpress' ); ?></p> | |
| 717 | + | |
| 718 | + <?php | |
| 719 | + | |
| 720 | + do_action( 'bbp_moderator_assignment_metabox', $post ); | |
| 721 | +} | |
| 722 | + | |
| 723 | +/** | |
| 724 | + * See who engaged with a topic | |
| 725 | + * | |
| 726 | + * @since 2.6.0 bbPress (r6333) | |
| 727 | + */ | |
| 728 | +function bbp_topic_engagements_metabox( $post ) { | |
| 729 | + | |
| 730 | + // Get user IDs | |
| 731 | + $user_ids = bbp_get_topic_engagements( $post->ID ); | |
| 732 | + | |
| 733 | + // Output | |
| 734 | + ?><p><?php | |
| 735 | + | |
| 736 | + // Relationships | |
| 737 | + $args = array( | |
| 738 | + 'include' => $user_ids | |
| 739 | + ); | |
| 740 | + | |
| 741 | + // Users were found | |
| 742 | + if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) : | |
| 743 | + bbp_metabox_user_links(); | |
| 744 | + | |
| 745 | + // No users | |
| 746 | + else : | |
| 747 | + esc_html_e( 'No users have engaged to this topic.', 'bbpress' ); | |
| 748 | + endif; | |
| 749 | + | |
| 750 | + ?></p><?php | |
| 751 | + | |
| 752 | + do_action( 'bbp_topic_engagements_metabox', $post ); | |
| 753 | +} | |
| 754 | + | |
| 755 | +/** | |
| 756 | + * See who marked a topic as a favorite | |
| 757 | + * | |
| 758 | + * @since 2.6.0 bbPress (r6197) | |
| 759 | + * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query | |
| 760 | + */ | |
| 761 | +function bbp_topic_favorites_metabox( $post ) { | |
| 762 | + | |
| 763 | + // Get user IDs | |
| 764 | + $user_ids = bbp_get_topic_favoriters( $post->ID ); | |
| 765 | + | |
| 766 | + // Output | |
| 767 | + ?><p><?php | |
| 768 | + | |
| 769 | + // Relationships | |
| 770 | + $args = array( | |
| 771 | + 'include' => $user_ids | |
| 772 | + ); | |
| 773 | + | |
| 774 | + // Users were found | |
| 775 | + if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) : | |
| 776 | + bbp_metabox_user_links(); | |
| 777 | + | |
| 778 | + // No users | |
| 779 | + else : | |
| 780 | + esc_html_e( 'No users have favorited this topic.', 'bbpress' ); | |
| 781 | + endif; | |
| 782 | + | |
| 783 | + ?></p><?php | |
| 784 | + | |
| 785 | + do_action( 'bbp_favorites_metabox', $post ); | |
| 786 | +} | |
| 787 | + | |
| 788 | +/** | |
| 789 | + * See who is subscribed to a topic | |
| 790 | + * | |
| 791 | + * @since 2.6.0 bbPress (r6197) | |
| 792 | + * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query | |
| 793 | + */ | |
| 794 | +function bbp_topic_subscriptions_metabox( $post ) { | |
| 795 | + | |
| 796 | + // Current user subscription | |
| 797 | + $input_value = bbp_is_user_subscribed( bbp_get_current_user_id(), $post->ID ) | |
| 798 | + ? 'bbp_subscribe' // maintain existing subscription | |
| 799 | + : ''; // do not add or remove subscription | |
| 800 | + | |
| 801 | + // Get user IDs | |
| 802 | + $user_ids = bbp_get_subscribers( $post->ID ); | |
| 803 | + | |
| 804 | + // Output | |
| 805 | + ?> | |
| 806 | + <input name="bbp_topic_subscription" id="bbp_topic_subscription" type="hidden" value="<?php echo esc_attr( $input_value ); ?>" /> | |
| 807 | + <p><?php | |
| 808 | + | |
| 809 | + // Relationships | |
| 810 | + $args = array( | |
| 811 | + 'include' => $user_ids | |
| 812 | + ); | |
| 813 | + | |
| 814 | + // Users were found | |
| 815 | + if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) : | |
| 816 | + bbp_metabox_user_links(); | |
| 817 | + | |
| 818 | + // No users | |
| 819 | + else : | |
| 820 | + esc_html_e( 'No users have subscribed to this topic.', 'bbpress' ); | |
| 821 | + endif; | |
| 822 | + | |
| 823 | + ?></p><?php | |
| 824 | + | |
| 825 | + do_action( 'bbp_subscriptions_metabox', $post ); | |
| 826 | +} | |
| 827 | + | |
| 828 | +/** | |
| 829 | + * See who is subscribed to a forum | |
| 830 | + * | |
| 831 | + * @since 2.6.0 bbPress (r6197) | |
| 832 | + * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query | |
| 833 | + */ | |
| 834 | +function bbp_forum_subscriptions_metabox( $post ) { | |
| 835 | + | |
| 836 | + // Get user IDs | |
| 837 | + $user_ids = bbp_get_subscribers( $post->ID ); | |
| 838 | + | |
| 839 | + // Output | |
| 840 | + ?><p><?php | |
| 841 | + | |
| 842 | + // Relationships | |
| 843 | + $args = array( | |
| 844 | + 'include' => $user_ids | |
| 845 | + ); | |
| 846 | + | |
| 847 | + // Users were found | |
| 848 | + if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) : | |
| 849 | + bbp_metabox_user_links(); | |
| 850 | + | |
| 851 | + // No users | |
| 852 | + else : | |
| 853 | + esc_html_e( 'No users have subscribed to this forum.', 'bbpress' ); | |
| 854 | + endif; | |
| 855 | + | |
| 856 | + ?></p><?php | |
| 857 | + | |
| 858 | + do_action( 'bbp_forum_subscriptions_metabox', $post ); | |
| 859 | +} | |
| 860 | + | |
| 861 | +/** | |
| 862 | + * Loop through queried metabox users, and output links to their avatars | |
| 863 | + * | |
| 864 | + * Developers Note: This function may change in a future release to include | |
| 865 | + * additional actions, so do not use this function in any third party plugin. | |
| 866 | + * | |
| 867 | + * @since 2.6.0 bbPress (r6913) | |
| 868 | + */ | |
| 869 | +function bbp_metabox_user_links() { | |
| 870 | + | |
| 871 | + // Loop through users | |
| 872 | + while ( bbp_users() ) { | |
| 873 | + | |
| 874 | + // Set the iterator | |
| 875 | + bbp_the_user(); | |
| 876 | + | |
| 877 | + // Get the user ID, URL, and Avatar | |
| 878 | + $user_id = bbp_get_user_id(); | |
| 879 | + $user_url = bbp_get_user_profile_url( $user_id ); | |
| 880 | + $user_avatar = get_avatar( | |
| 881 | + $user_id, | |
| 882 | + 32, | |
| 883 | + '', | |
| 884 | + '', | |
| 885 | + array( | |
| 886 | + 'force_display' => true | |
| 887 | + ) | |
| 888 | + ); | |
| 889 | + | |
| 890 | + // Output a link to the user avatar | |
| 891 | + echo '<a href="' . esc_url( $user_url ) . '">' . $user_avatar . '</a>'; | |
| 892 | + } | |
| 495 | 893 | } |