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