PluginProbe
bbPress / 2.1-rc4
bbPress v2.1-rc4
2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 All 72 releases
bbpress / bbp-admin / bbp-metaboxes.php

bbp-metaboxes.php in bbPress 2.1-rc4, at bbp-admin/bbp-metaboxes.php

489 lines 14.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress Admin Metaboxes
5 *
6 * @package bbPress
7 * @subpackage Administration
8 */
9
10 /** Dashboard *****************************************************************/
11
12 /**
13 * bbPress Dashboard Right Now Widget
14 *
15 * Adds a dashboard widget with forum statistics
16 *
17 * @since bbPress (r2770)
18 *
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
34 */
35 function bbp_dashboard_widget_right_now() {
36
37 // Get the statistics and extract them
38 extract( bbp_get_statistics(), EXTR_SKIP ); ?>
39
40 <div class="table table_content">
41
42 <p class="sub"><?php _e( 'Discussion', 'bbpress' ); ?></p>
43
44 <table>
45
46 <tr class="first">
47
48 <?php
49 $num = $forum_count;
50 $text = _n( 'Forum', 'Forums', $forum_count, 'bbpress' );
51 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>';
55 }
56 ?>
57
58 <td class="first b b-forums"><?php echo $num; ?></td>
59 <td class="t forums"><?php echo $text; ?></td>
60
61 </tr>
62
63 <tr>
64
65 <?php
66 $num = $topic_count;
67 $text = _n( 'Topic', 'Topics', $topic_count, 'bbpress' );
68 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>';
72 }
73 ?>
74
75 <td class="first b b-topics"><?php echo $num; ?></td>
76 <td class="t topics"><?php echo $text; ?></td>
77
78 </tr>
79
80 <tr>
81
82 <?php
83 $num = $reply_count;
84 $text = _n( 'Reply', 'Replies', $reply_count, 'bbpress' );
85 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>';
89 }
90 ?>
91
92 <td class="first b b-replies"><?php echo $num; ?></td>
93 <td class="t replies"><?php echo $text; ?></td>
94
95 </tr>
96
97 <tr>
98
99 <?php
100 $num = $topic_tag_count;
101 $text = _n( 'Topic Tag', 'Topic Tags', $topic_tag_count, 'bbpress' );
102 if ( current_user_can( 'manage_topic_tags' ) ) {
103 $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' ) );
104 $num = '<a href="' . $link . '">' . $num . '</a>';
105 $text = '<a href="' . $link . '">' . $text . '</a>';
106 }
107 ?>
108
109 <td class="first b b-topic_tags"><span class="total-count"><?php echo $num; ?></span></td>
110 <td class="t topic_tags"><?php echo $text; ?></td>
111
112 </tr>
113
114 <?php do_action( 'bbp_dashboard_widget_right_now_content_table_end' ); ?>
115
116 </table>
117
118 </div>
119
120
121 <div class="table table_discussion">
122
123 <p class="sub"><?php _e( 'Users &amp; Moderation', 'bbpress' ); ?></p>
124
125 <table>
126
127 <tr class="first">
128
129 <?php
130 $num = $user_count;
131 $text = _n( 'User', 'Users', $user_count, 'bbpress' );
132 if ( current_user_can( 'edit_users' ) ) {
133 $link = get_admin_url( null, 'users.php' );
134 $num = '<a href="' . $link . '">' . $num . '</a>';
135 $text = '<a href="' . $link . '">' . $text . '</a>';
136 }
137 ?>
138
139 <td class="b b-users"><span class="total-count"><?php echo $num; ?></span></td>
140 <td class="last t users"><?php echo $text; ?></td>
141
142 </tr>
143
144 <?php if ( isset( $topic_count_hidden ) ) : ?>
145
146 <tr>
147
148 <?php
149 $num = $topic_count_hidden;
150 $text = _n( 'Hidden Topic', 'Hidden Topics', $topic_count_hidden, 'bbpress' );
151 $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) );
152 if ( '0' != $num ) {
153 $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link );
154 }
155 $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $num . '</a>';
156 $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $text . '</a>';
157 ?>
158
159 <td class="b b-hidden-topics"><?php echo $num; ?></td>
160 <td class="last t hidden-replies"><?php echo $text; ?></td>
161
162 </tr>
163
164 <?php endif; ?>
165
166 <?php if ( isset( $reply_count_hidden ) ) : ?>
167
168 <tr>
169
170 <?php
171 $num = $reply_count_hidden;
172 $text = _n( 'Hidden Reply', 'Hidden Replies', $reply_count_hidden, 'bbpress' );
173 $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) );
174 if ( '0' != $num ) {
175 $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link );
176 }
177 $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $num . '</a>';
178 $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $text . '</a>';
179 ?>
180
181 <td class="b b-hidden-replies"><?php echo $num; ?></td>
182 <td class="last t hidden-replies"><?php echo $text; ?></td>
183
184 </tr>
185
186 <?php endif; ?>
187
188 <?php if ( isset( $empty_topic_tag_count ) ) : ?>
189
190 <tr>
191
192 <?php
193 $num = $empty_topic_tag_count;
194 $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $empty_topic_tag_count, 'bbpress' );
195 $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' ) );
196 $num = '<a href="' . $link . '">' . $num . '</a>';
197 $text = '<a class="waiting" href="' . $link . '">' . $text . '</a>';
198 ?>
199
200 <td class="b b-hidden-topic-tags"><?php echo $num; ?></td>
201 <td class="last t hidden-topic-tags"><?php echo $text; ?></td>
202
203 </tr>
204
205 <?php endif; ?>
206
207 <?php do_action( 'bbp_dashboard_widget_right_now_discussion_table_end' ); ?>
208
209 </table>
210
211 </div>
212
213 <?php do_action( 'bbp_dashboard_widget_right_now_table_end' ); ?>
214
215 <div class="versions">
216
217 <span id="wp-version-message">
218 <?php printf( __( 'You are using <span class="b">bbPress %s</span>.', 'bbpress' ), bbp_get_version() ); ?>
219 </span>
220
221 </div>
222
223 <br class="clear" />
224
225 <?php
226
227 do_action( 'bbp_dashboard_widget_right_now_end' );
228 }
229
230 /** Forums ********************************************************************/
231
232 /**
233 * Forum metabox
234 *
235 * The metabox that holds all of the additional forum information
236 *
237 * @since bbPress (r2744)
238 *
239 * @uses bbp_is_forum_closed() To check if a forum is closed or not
240 * @uses bbp_is_forum_category() To check if a forum is a category or not
241 * @uses bbp_is_forum_private() To check if a forum is private or not
242 * @uses bbp_dropdown() To show a dropdown of the forums for forum parent
243 * @uses do_action() Calls 'bbp_forum_metabox'
244 */
245 function bbp_forum_metabox() {
246
247 // Post ID
248 $post_id = get_the_ID();
249 $post_parent = bbp_get_global_post_field( 'post_parent', 'raw' );
250 $menu_order = bbp_get_global_post_field( 'menu_order', 'edit' );
251
252 /** Type ******************************************************************/
253
254 ?>
255
256 <p>
257 <strong class="label"><?php _e( 'Type:', 'bbpress' ); ?></strong>
258 <label class="screen-reader-text" for="bbp_forum_type_select"><?php _e( 'Type:', 'bbpress' ) ?></label>
259 <?php bbp_form_forum_type_dropdown( $post_id ); ?>
260 </p>
261
262 <?php
263
264 /** Status ****************************************************************/
265
266 ?>
267
268 <p>
269 <strong class="label"><?php _e( 'Status:', 'bbpress' ); ?></strong>
270 <label class="screen-reader-text" for="bbp_forum_status_select"><?php _e( 'Status:', 'bbpress' ) ?></label>
271 <?php bbp_form_forum_status_dropdown( $post_id ); ?>
272 </p>
273
274 <?php
275
276 /** Visibility ************************************************************/
277
278 ?>
279
280 <p>
281 <strong class="label"><?php _e( 'Visibility:', 'bbpress' ); ?></strong>
282 <label class="screen-reader-text" for="bbp_forum_visibility_select"><?php _e( 'Visibility:', 'bbpress' ) ?></label>
283 <?php bbp_form_forum_visibility_dropdown( $post_id ); ?>
284 </p>
285
286 <hr />
287
288 <?php
289
290 /** Parent ****************************************************************/
291
292 ?>
293
294 <p>
295 <strong class="label"><?php _e( 'Parent:', 'bbpress' ); ?></strong>
296 <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum Parent', 'bbpress' ); ?></label>
297
298 <?php
299 bbp_dropdown( array(
300 'exclude' => $post_id,
301 'selected' => $post_parent,
302 'show_none' => __( '(No Parent)', 'bbpress' ),
303 'select_id' => 'parent_id',
304 'disable_categories' => false
305 ) );
306 ?>
307
308 </p>
309
310 <p>
311 <strong class="label"><?php _e( 'Order:', 'bbpress' ); ?></strong>
312 <label class="screen-reader-text" for="menu_order"><?php _e( 'Forum Order', 'bbpress' ); ?></label>
313 <input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo $menu_order; ?>" />
314 </p>
315
316 <?php
317 wp_nonce_field( 'bbp_forum_metabox_save', 'bbp_forum_metabox' );
318 do_action( 'bbp_forum_metabox', $post_id );
319 }
320
321 /** Topics ********************************************************************/
322
323 /**
324 * Topic metabox
325 *
326 * The metabox that holds all of the additional topic information
327 *
328 * @since bbPress (r2464)
329 *
330 * @uses bbp_get_topic_forum_id() To get the topic forum id
331 * @uses bbp_dropdown() To show a dropdown of the forums for topic parent
332 * @uses do_action() Calls 'bbp_topic_metabox'
333 */
334 function bbp_topic_metabox() {
335
336 // Post ID
337 $post_id = get_the_ID();
338
339 $args = array(
340 'selected' => bbp_get_topic_forum_id( $post_id ),
341 'select_id' => 'parent_id',
342 'show_none' => is_super_admin() ? __( '(No Forum)', 'bbpress' ) : '',
343 ); ?>
344
345 <p><strong><?php _e( 'Forum', 'bbpress' ); ?></strong></p>
346
347 <p>
348 <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum', 'bbpress' ); ?></label>
349 <?php bbp_dropdown( $args ); ?>
350 </p>
351
352 <p><strong><?php _e( 'Topic Type', 'bbpress' ); ?></strong></p>
353
354 <p>
355 <label class="screen-reader-text" for="bbp_stick_topic"><?php _e( 'Topic Type', 'bbpress' ); ?></label>
356 <?php bbp_topic_type_select( array( 'topic_id' => $post_id ) ); ?>
357 </p>
358
359 <?php
360 wp_nonce_field( 'bbp_topic_metabox_save', 'bbp_topic_metabox' );
361 do_action( 'bbp_topic_metabox', $post_id );
362 }
363
364 /** Replies *******************************************************************/
365
366 /**
367 * Reply metabox
368 *
369 * The metabox that holds all of the additional reply information
370 *
371 * @since bbPress (r2464)
372 *
373 * @uses bbp_get_topic_post_type() To get the topic post type
374 * @uses bbp_dropdown() To show a dropdown of the topics for reply parent
375 * @uses do_action() Calls 'bbp_reply_metabox'
376 */
377 function bbp_reply_metabox() {
378
379 // Post ID
380 $post_id = get_the_ID();
381
382 // Get some meta
383 $reply_topic_id = bbp_get_reply_topic_id( $post_id );
384 $reply_forum_id = bbp_get_reply_forum_id( $post_id );
385
386 // Allow individual manipulation of reply forum
387 if ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate' ) ) :
388
389 // Forums
390 $args = array(
391 'selected' => $reply_forum_id,
392 'select_id' => 'bbp_forum_id',
393 'show_none' => __( '(Use Forum of Topic)', 'bbpress' )
394 ); ?>
395
396 <p><strong><?php _e( 'Forum', 'bbpress' ); ?></strong></p>
397
398 <p>
399 <label class="screen-reader-text" for="bbp_forum_id"><?php _e( 'Forum', 'bbpress' ); ?></label>
400
401 <?php bbp_dropdown( $args ); ?>
402
403 </p>
404
405 <?php endif;
406
407 // Topics
408 $args = array(
409 'post_type' => bbp_get_topic_post_type(),
410 'selected' => $reply_topic_id,
411 'select_id' => 'parent_id',
412 'orderby' => 'post_date',
413 'numberposts' => '250',
414 'show_none' => is_super_admin() ? __( '(No Topic)', 'bbpress' ) : '',
415 );
416
417 // Allow the dropdown to be filtered, to extend or limit the available
418 // topics to choose as the reply parent.
419 $args = apply_filters( 'bbp_reply_parent_dropdown', $args ); ?>
420
421 <p><strong><?php _e( 'Topic', 'bbpress' ); ?></strong></p>
422
423 <p>
424 <label class="screen-reader-text" for="parent_id"><?php _e( 'Topic', 'bbpress' ); ?></label>
425
426 <?php bbp_dropdown( $args ); ?>
427
428 </p>
429
430 <?php
431 wp_nonce_field( 'bbp_reply_metabox_save', 'bbp_reply_metabox' );
432 do_action( 'bbp_reply_metabox', $post_id );
433 }
434
435 /** Users *********************************************************************/
436
437 /**
438 * Anonymous user information metabox
439 *
440 * @since bbPress (r2828)
441 *
442 * @uses bbp_is_reply_anonymous() To check if reply is anonymous
443 * @uses bbp_is_topic_anonymous() To check if topic is anonymous
444 * @uses get_the_ID() To get the global post ID
445 * @uses get_post_meta() To get the author user information
446 */
447 function bbp_author_metabox() {
448
449 // Post ID
450 $post_id = get_the_ID();
451
452 // Show extra bits if topic/reply is anonymous
453 if ( bbp_is_reply_anonymous( $post_id ) || bbp_is_topic_anonymous( $post_id ) ) : ?>
454
455 <p><strong><?php _e( 'Name', 'bbpress' ); ?></strong></p>
456
457 <p>
458 <label class="screen-reader-text" for="bbp_anonymous_name"><?php _e( 'Name', 'bbpress' ); ?></label>
459 <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 ) ); ?>" size="25" />
460 </p>
461
462 <p><strong><?php _e( 'Email', 'bbpress' ); ?></strong></p>
463
464 <p>
465 <label class="screen-reader-text" for="bbp_anonymous_email"><?php _e( 'Email', 'bbpress' ); ?></label>
466 <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 ) ); ?>" size="25" />
467 </p>
468
469 <p><strong><?php _e( 'Website', 'bbpress' ); ?></strong></p>
470
471 <p>
472 <label class="screen-reader-text" for="bbp_anonymous_website"><?php _e( 'Website', 'bbpress' ); ?></label>
473 <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 ) ); ?>" size="25" />
474 </p>
475
476 <?php endif; ?>
477
478 <p><strong><?php _e( 'IP Address', 'bbpress' ); ?></strong></p>
479
480 <p>
481 <label class="screen-reader-text" for="bbp_author_ip_address"><?php _e( 'IP Address', 'bbpress' ); ?></label>
482 <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 ) ); ?>" size="25" disabled="disabled" />
483 </p>
484
485 <?php
486
487 do_action( 'bbp_author_metabox', $post_id );
488 }
489