| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* bbPress Admin Metaboxes |
| 5 |
* |
| 6 |
* @package bbPress |
| 7 |
* @subpackage Administration |
| 8 |
*/ |
| 9 |
|
| 10 |
/** Dashboard *****************************************************************/ |
| 11 |
|
| 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 |
/** |
| 109 |
* bbPress Dashboard Right Now Widget |
| 110 |
* |
| 111 |
* Adds a dashboard widget with forum statistics |
| 112 |
* |
| 113 |
* @since 2.0.0 bbPress (r2770) |
| 114 |
* |
| 115 |
* @deprecated 2.6.0 bbPress (r5268) |
| 116 |
*/ |
| 117 |
function bbp_dashboard_widget_right_now() { |
| 118 |
|
| 119 |
// Get the statistics |
| 120 |
$r = bbp_get_statistics(); ?> |
| 121 |
|
| 122 |
<div class="table table_content"> |
| 123 |
|
| 124 |
<p class="sub"><?php esc_html_e( 'Discussion', 'bbpress' ); ?></p> |
| 125 |
|
| 126 |
<table> |
| 127 |
|
| 128 |
<tr class="first"> |
| 129 |
|
| 130 |
<?php |
| 131 |
$num = $r['forum_count']; |
| 132 |
$text = _n( 'Forum', 'Forums', $r['forum_count_int'], 'bbpress' ); |
| 133 |
if ( current_user_can( 'publish_forums' ) ) { |
| 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>'; |
| 137 |
} |
| 138 |
?> |
| 139 |
|
| 140 |
<td class="first b b-forums"><?php echo $num; ?></td> |
| 141 |
<td class="t forums"><?php echo $text; ?></td> |
| 142 |
|
| 143 |
</tr> |
| 144 |
|
| 145 |
<tr> |
| 146 |
|
| 147 |
<?php |
| 148 |
$num = $r['topic_count']; |
| 149 |
$text = _n( 'Topic', 'Topics', $r['topic_count_int'], 'bbpress' ); |
| 150 |
if ( current_user_can( 'publish_topics' ) ) { |
| 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>'; |
| 154 |
} |
| 155 |
?> |
| 156 |
|
| 157 |
<td class="first b b-topics"><?php echo $num; ?></td> |
| 158 |
<td class="t topics"><?php echo $text; ?></td> |
| 159 |
|
| 160 |
</tr> |
| 161 |
|
| 162 |
<tr> |
| 163 |
|
| 164 |
<?php |
| 165 |
$num = $r['reply_count']; |
| 166 |
$text = _n( 'Reply', 'Replies', $r['reply_count_int'], 'bbpress' ); |
| 167 |
if ( current_user_can( 'publish_replies' ) ) { |
| 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>'; |
| 171 |
} |
| 172 |
?> |
| 173 |
|
| 174 |
<td class="first b b-replies"><?php echo $num; ?></td> |
| 175 |
<td class="t replies"><?php echo $text; ?></td> |
| 176 |
|
| 177 |
</tr> |
| 178 |
|
| 179 |
<?php if ( bbp_allow_topic_tags() ) : ?> |
| 180 |
|
| 181 |
<tr> |
| 182 |
|
| 183 |
<?php |
| 184 |
$num = $r['topic_tag_count']; |
| 185 |
$text = _n( 'Topic Tag', 'Topic Tags', $r['topic_tag_count_int'], 'bbpress' ); |
| 186 |
if ( current_user_can( 'manage_topic_tags' ) ) { |
| 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>'; |
| 194 |
} |
| 195 |
?> |
| 196 |
|
| 197 |
<td class="first b b-topic_tags"><span class="total-count"><?php echo $num; ?></span></td> |
| 198 |
<td class="t topic_tags"><?php echo $text; ?></td> |
| 199 |
|
| 200 |
</tr> |
| 201 |
|
| 202 |
<?php endif; ?> |
| 203 |
|
| 204 |
<?php do_action( 'bbp_dashboard_widget_right_now_content_table_end' ); ?> |
| 205 |
|
| 206 |
</table> |
| 207 |
|
| 208 |
</div> |
| 209 |
|
| 210 |
|
| 211 |
<div class="table table_discussion"> |
| 212 |
|
| 213 |
<p class="sub"><?php esc_html_e( 'Users & Moderation', 'bbpress' ); ?></p> |
| 214 |
|
| 215 |
<table> |
| 216 |
|
| 217 |
<tr class="first"> |
| 218 |
|
| 219 |
<?php |
| 220 |
$num = $r['user_count']; |
| 221 |
$text = _n( 'User', 'Users', $r['user_count_int'], 'bbpress' ); |
| 222 |
if ( current_user_can( 'edit_users' ) ) { |
| 223 |
$link = admin_url( 'users.php' ); |
| 224 |
$num = '<a href="' . $link . '">' . $num . '</a>'; |
| 225 |
$text = '<a href="' . $link . '">' . $text . '</a>'; |
| 226 |
} |
| 227 |
?> |
| 228 |
|
| 229 |
<td class="b b-users"><span class="total-count"><?php echo $num; ?></span></td> |
| 230 |
<td class="last t users"><?php echo $text; ?></td> |
| 231 |
|
| 232 |
</tr> |
| 233 |
|
| 234 |
<?php if ( isset( $r['topic_count_hidden'] ) ) : ?> |
| 235 |
|
| 236 |
<tr> |
| 237 |
|
| 238 |
<?php |
| 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 ) { |
| 243 |
$link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); |
| 244 |
} |
| 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>'; |
| 247 |
?> |
| 248 |
|
| 249 |
<td class="b b-hidden-topics"><?php echo $num; ?></td> |
| 250 |
<td class="last t hidden-replies"><?php echo $text; ?></td> |
| 251 |
|
| 252 |
</tr> |
| 253 |
|
| 254 |
<?php endif; ?> |
| 255 |
|
| 256 |
<?php if ( isset( $r['reply_count_hidden'] ) ) : ?> |
| 257 |
|
| 258 |
<tr> |
| 259 |
|
| 260 |
<?php |
| 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 ) { |
| 265 |
$link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); |
| 266 |
} |
| 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>'; |
| 269 |
?> |
| 270 |
|
| 271 |
<td class="b b-hidden-replies"><?php echo $num; ?></td> |
| 272 |
<td class="last t hidden-replies"><?php echo $text; ?></td> |
| 273 |
|
| 274 |
</tr> |
| 275 |
|
| 276 |
<?php endif; ?> |
| 277 |
|
| 278 |
<?php if ( bbp_allow_topic_tags() && isset( $r['empty_topic_tag_count'] ) ) : ?> |
| 279 |
|
| 280 |
<tr> |
| 281 |
|
| 282 |
<?php |
| 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>'; |
| 292 |
?> |
| 293 |
|
| 294 |
<td class="b b-hidden-topic-tags"><?php echo $num; ?></td> |
| 295 |
<td class="last t hidden-topic-tags"><?php echo $text; ?></td> |
| 296 |
|
| 297 |
</tr> |
| 298 |
|
| 299 |
<?php endif; ?> |
| 300 |
|
| 301 |
<?php do_action( 'bbp_dashboard_widget_right_now_discussion_table_end' ); ?> |
| 302 |
|
| 303 |
</table> |
| 304 |
|
| 305 |
</div> |
| 306 |
|
| 307 |
<?php do_action( 'bbp_dashboard_widget_right_now_table_end' ); ?> |
| 308 |
|
| 309 |
<div class="versions"> |
| 310 |
|
| 311 |
<span id="wp-version-message"> |
| 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 |
?> |
| 319 |
</span> |
| 320 |
|
| 321 |
</div> |
| 322 |
|
| 323 |
<br class="clear" /> |
| 324 |
|
| 325 |
<?php |
| 326 |
|
| 327 |
do_action( 'bbp_dashboard_widget_right_now_end' ); |
| 328 |
} |
| 329 |
|
| 330 |
/** Forums ********************************************************************/ |
| 331 |
|
| 332 |
/** |
| 333 |
* Forum meta-box |
| 334 |
* |
| 335 |
* The meta-box that holds all of the additional forum information |
| 336 |
* |
| 337 |
* @since 2.0.0 bbPress (r2744) |
| 338 |
*/ |
| 339 |
function bbp_forum_metabox( $post ) { |
| 340 |
|
| 341 |
// Post ID |
| 342 |
$post_parent = bbp_get_global_post_field( 'post_parent', 'raw' ); |
| 343 |
$menu_order = bbp_get_global_post_field( 'menu_order', 'edit' ); |
| 344 |
|
| 345 |
/** Type ******************************************************************/ |
| 346 |
|
| 347 |
?> |
| 348 |
|
| 349 |
<p> |
| 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 ) ); ?> |
| 353 |
</p> |
| 354 |
|
| 355 |
<?php |
| 356 |
|
| 357 |
/** Status ****************************************************************/ |
| 358 |
|
| 359 |
?> |
| 360 |
|
| 361 |
<p> |
| 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 ) ); ?> |
| 365 |
</p> |
| 366 |
|
| 367 |
<?php |
| 368 |
|
| 369 |
/** Visibility ************************************************************/ |
| 370 |
|
| 371 |
?> |
| 372 |
|
| 373 |
<p> |
| 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 ) ); ?> |
| 377 |
</p> |
| 378 |
|
| 379 |
<hr /> |
| 380 |
|
| 381 |
<?php |
| 382 |
|
| 383 |
/** Parent ****************************************************************/ |
| 384 |
|
| 385 |
?> |
| 386 |
|
| 387 |
<p> |
| 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, |
| 400 |
|
| 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 |
?> |
| 410 |
</p> |
| 411 |
|
| 412 |
<p> |
| 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> |
| 415 |
<input name="menu_order" type="number" step="1" size="4" id="menu_order" value="<?php echo esc_attr( $menu_order ); ?>" /> |
| 416 |
</p> |
| 417 |
|
| 418 |
<input name="ping_status" type="hidden" id="ping_status" value="open" /> |
| 419 |
|
| 420 |
<?php |
| 421 |
wp_nonce_field( 'bbp_forum_metabox_save', 'bbp_forum_metabox' ); |
| 422 |
do_action( 'bbp_forum_metabox', $post ); |
| 423 |
} |
| 424 |
|
| 425 |
/** Topics ********************************************************************/ |
| 426 |
|
| 427 |
/** |
| 428 |
* Topic meta-box |
| 429 |
* |
| 430 |
* The meta-box that holds all of the additional topic information |
| 431 |
* |
| 432 |
* @since 2.0.0 bbPress (r2464) |
| 433 |
*/ |
| 434 |
function bbp_topic_metabox( $post ) { |
| 435 |
|
| 436 |
/** Type ******************************************************************/ |
| 437 |
|
| 438 |
?> |
| 439 |
|
| 440 |
<p> |
| 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 ) ); ?> |
| 444 |
</p> |
| 445 |
|
| 446 |
<?php |
| 447 |
|
| 448 |
/** Status ****************************************************************/ |
| 449 |
|
| 450 |
?> |
| 451 |
|
| 452 |
<p> |
| 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> |
| 463 |
|
| 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 |
?> |
| 495 |
</p> |
| 496 |
|
| 497 |
<input name="ping_status" type="hidden" id="ping_status" value="open" /> |
| 498 |
|
| 499 |
<?php |
| 500 |
wp_nonce_field( 'bbp_topic_metabox_save', 'bbp_topic_metabox' ); |
| 501 |
do_action( 'bbp_topic_metabox', $post ); |
| 502 |
} |
| 503 |
|
| 504 |
/** Replies *******************************************************************/ |
| 505 |
|
| 506 |
/** |
| 507 |
* Reply meta-box |
| 508 |
* |
| 509 |
* The meta-box that holds all of the additional reply information |
| 510 |
* |
| 511 |
* @since 2.0.0 bbPress (r2464) |
| 512 |
*/ |
| 513 |
function bbp_reply_metabox( $post ) { |
| 514 |
|
| 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 ); |
| 519 |
|
| 520 |
/** Status ****************************************************************/ |
| 521 |
|
| 522 |
?> |
| 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 |
|
| 545 |
<p> |
| 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' => '', |
| 558 |
|
| 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 |
?> |
| 568 |
</p> |
| 569 |
|
| 570 |
<?php endif; |
| 571 |
|
| 572 |
/** Topic *****************************************************************/ |
| 573 |
|
| 574 |
?> |
| 575 |
|
| 576 |
<p> |
| 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' ) ); ?>" /> |
| 580 |
</p> |
| 581 |
|
| 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 |
| 604 |
wp_nonce_field( 'bbp_reply_metabox_save', 'bbp_reply_metabox' ); |
| 605 |
do_action( 'bbp_reply_metabox', $post ); |
| 606 |
} |
| 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 |
|
| 647 |
/** Users *********************************************************************/ |
| 648 |
|
| 649 |
/** |
| 650 |
* Anonymous user information meta-box |
| 651 |
* |
| 652 |
* @since 2.0.0 bbPress (r2828) |
| 653 |
* |
| 654 |
* @param WP_Post $post The current post object |
| 655 |
*/ |
| 656 |
function bbp_author_metabox( $post ) { |
| 657 |
|
| 658 |
// Show extra bits if topic/reply is anonymous |
| 659 |
if ( bbp_is_reply_anonymous( $post->ID ) || bbp_is_topic_anonymous( $post->ID ) ) : ?> |
| 660 |
|
| 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> |
| 666 |
|
| 667 |
<p> |
| 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 ) ); ?>" /> |
| 671 |
</p> |
| 672 |
|
| 673 |
<p> |
| 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 ) ); ?>" /> |
| 677 |
</p> |
| 678 |
|
| 679 |
<?php else : ?> |
| 680 |
|
| 681 |
<p> |
| 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' ) ); ?>" /> |
| 685 |
</p> |
| 686 |
|
| 687 |
<?php endif; ?> |
| 688 |
|
| 689 |
<p> |
| 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" /> |
| 693 |
</p> |
| 694 |
|
| 695 |
<?php |
| 696 |
|
| 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 |
} |
| 893 |
} |
| 894 |
|