PluginProbe
bbPress / 2.0-rc-4
bbPress v2.0-rc-4
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.0-rc-4, at bbp-admin/bbp-metaboxes.php

500 lines 15.7 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 $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $num . '</a>';
153 $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $text . '</a>';
154 ?>
155
156 <td class="b b-hidden-topics"><?php echo $num; ?></td>
157 <td class="last t hidden-replies"><?php echo $text; ?></td>
158
159 </tr>
160
161 <?php endif; ?>
162
163 <?php if ( isset( $reply_count_hidden ) ) : ?>
164
165 <tr>
166
167 <?php
168 $num = $reply_count_hidden;
169 $text = _n( 'Hidden Reply', 'Hidden Replies', $reply_count_hidden, 'bbpress' );
170 $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) );
171 $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $num . '</a>';
172 $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $text . '</a>';
173 ?>
174
175 <td class="b b-hidden-replies"><?php echo $num; ?></td>
176 <td class="last t hidden-replies"><?php echo $text; ?></td>
177
178 </tr>
179
180 <?php endif; ?>
181
182 <?php if ( isset( $empty_topic_tag_count ) ) : ?>
183
184 <tr>
185
186 <?php
187 $num = $empty_topic_tag_count;
188 $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $empty_topic_tag_count, 'bbpress' );
189 $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' ) );
190 $num = '<a href="' . $link . '">' . $num . '</a>';
191 $text = '<a class="waiting" href="' . $link . '">' . $text . '</a>';
192 ?>
193
194 <td class="b b-hidden-topic-tags"><?php echo $num; ?></td>
195 <td class="last t hidden-topic-tags"><?php echo $text; ?></td>
196
197 </tr>
198
199 <?php endif; ?>
200
201 <?php do_action( 'bbp_dashboard_widget_right_now_discussion_table_end' ); ?>
202
203 </table>
204
205 </div>
206
207 <?php do_action( 'bbp_dashboard_widget_right_now_table_end' ); ?>
208
209 <div class="versions">
210
211 <p>
212 <?php
213 if ( current_theme_supports( 'bbpress' ) )
214 _e( 'Theme is using <strong>custom bbPress</strong> styling.', 'bbpress' );
215 else
216 _e( 'Theme is using <strong>default bbPress</strong> styling.', 'bbpress' );
217 ?>
218 </p>
219
220 <span id="wp-version-message">
221 <?php printf( __( 'You are using <span class="b">bbPress %s</span>.', 'bbpress' ), bbp_get_version() ); ?>
222 </span>
223
224 </div>
225
226 <br class="clear" />
227
228 <?php
229
230 do_action( 'bbp_dashboard_widget_right_now_end' );
231 }
232
233 /** Forums ********************************************************************/
234
235 /**
236 * Forum metabox
237 *
238 * The metabox that holds all of the additional forum information
239 *
240 * @since bbPress (r2744)
241 *
242 * @uses bbp_is_forum_closed() To check if a forum is closed or not
243 * @uses bbp_is_forum_category() To check if a forum is a category or not
244 * @uses bbp_is_forum_private() To check if a forum is private or not
245 * @uses bbp_dropdown() To show a dropdown of the forums for forum parent
246 * @uses do_action() Calls 'bbp_forum_metabox'
247 */
248 function bbp_forum_metabox() {
249 global $post;
250
251 /** Type ******************************************************************/
252
253 $forum['type'] = array(
254 'forum' => __( 'Forum', 'bbpress' ),
255 'category' => __( 'Category', 'bbpress' )
256 );
257 $type_output = '<select name="bbp_forum_type" id="bbp_forum_type_select">' . "\n";
258
259 foreach( $forum['type'] as $value => $label )
260 $type_output .= "\t" . '<option value="' . $value . '"' . selected( bbp_is_forum_category( $post->ID ) ? 'category' : 'forum', $value, false ) . '>' . esc_html( $label ) . '</option>' . "\n";
261
262 $type_output .= '</select>';
263
264 /** Status ****************************************************************/
265
266 $forum['status'] = array(
267 'open' => __( 'Open', 'bbpress' ),
268 'closed' => __( 'Closed', 'bbpress' )
269 );
270 $status_output = '<select name="bbp_forum_status" id="bbp_forum_status_select">' . "\n";
271
272 foreach( $forum['status'] as $value => $label )
273 $status_output .= "\t" . '<option value="' . $value . '"' . selected( bbp_is_forum_closed( $post->ID, false ) ? 'closed' : 'open', $value, false ) . '>' . esc_html( $label ) . '</option>' . "\n";
274
275 $status_output .= '</select>';
276
277 /** Visibility ************************************************************/
278
279 $forum['visibility'] = array(
280 'publish' => __( 'Public', 'bbpress' ),
281 'private' => __( 'Private', 'bbpress' ),
282 'hidden' => __( 'Hidden', 'bbpress' )
283 );
284 $visibility_output = '<select name="bbp_forum_visibility" id="bbp_forum_visibility_select">' . "\n";
285
286 foreach( $forum['visibility'] as $value => $label )
287 $visibility_output .= "\t" . '<option value="' . $value . '"' . selected( bbp_get_forum_visibility( $post->ID ), $value, false ) . '>' . esc_html( $label ) . '</option>' . "\n";
288
289 $visibility_output .= '</select>';
290
291 /** Output ****************************************************************/ ?>
292
293 <p>
294 <strong class="label"><?php _e( 'Type:', 'bbpress' ); ?></strong>
295 <label class="screen-reader-text" for="bbp_forum_type_select"><?php _e( 'Type:', 'bbpress' ) ?></label>
296 <?php echo $type_output; ?>
297 </p>
298
299 <p>
300 <strong class="label"><?php _e( 'Status:', 'bbpress' ); ?></strong>
301 <label class="screen-reader-text" for="bbp_forum_status_select"><?php _e( 'Status:', 'bbpress' ) ?></label>
302 <?php echo $status_output; ?>
303 </p>
304
305 <p>
306 <strong class="label"><?php _e( 'Visibility:', 'bbpress' ); ?></strong>
307 <label class="screen-reader-text" for="bbp_forum_visibility_select"><?php _e( 'Visibility:', 'bbpress' ) ?></label>
308 <?php echo $visibility_output; ?>
309 </p>
310
311 <hr />
312
313 <p>
314 <strong class="label"><?php _e( 'Parent:', 'bbpress' ); ?></strong>
315 <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum Parent', 'bbpress' ); ?></label>
316
317 <?php
318 bbp_dropdown( array(
319 'exclude' => $post->ID,
320 'selected' => $post->post_parent,
321 'show_none' => __( '(No Parent)', 'bbpress' ),
322 'select_id' => 'parent_id',
323 'disable_categories' => false
324 ) );
325 ?>
326
327 </p>
328
329 <p>
330 <strong class="label"><?php _e( 'Order:', 'bbpress' ); ?></strong>
331 <label class="screen-reader-text" for="menu_order"><?php _e( 'Forum Order', 'bbpress' ); ?></label>
332 <input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" />
333 </p>
334
335 <?php
336
337 do_action( 'bbp_forum_metabox', $post->ID );
338 }
339
340 /** Topics ********************************************************************/
341
342 /**
343 * Topic metabox
344 *
345 * The metabox that holds all of the additional topic information
346 *
347 * @since bbPress (r2464)
348 *
349 * @uses bbp_get_topic_forum_id() To get the topic forum id
350 * @uses bbp_dropdown() To show a dropdown of the forums for topic parent
351 * @uses do_action() Calls 'bbp_topic_metabox'
352 */
353 function bbp_topic_metabox() {
354 global $post;
355
356 $args = array(
357 'selected' => bbp_get_topic_forum_id( $post->ID ),
358 'select_id' => 'parent_id',
359 'show_none' => is_super_admin() ? __( '(No Forum)', 'bbpress' ) : '',
360 ); ?>
361
362 <p><strong><?php _e( 'Forum', 'bbpress' ); ?></strong></p>
363
364 <p>
365 <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum', 'bbpress' ); ?></label>
366 <?php bbp_dropdown( $args ); ?>
367 </p>
368
369 <?php
370
371 do_action( 'bbp_topic_metabox', $post->ID );
372 }
373
374 /** Replies *******************************************************************/
375
376 /**
377 * Reply metabox
378 *
379 * The metabox that holds all of the additional reply information
380 *
381 * @since bbPress (r2464)
382 *
383 * @uses bbp_get_topic_post_type() To get the topic post type
384 * @uses bbp_dropdown() To show a dropdown of the topics for reply parent
385 * @uses do_action() Calls 'bbp_reply_metabox'
386 */
387 function bbp_reply_metabox() {
388 global $post;
389
390 // Get some meta
391 $reply_topic_id = bbp_get_reply_topic_id( $post->ID );
392 $reply_forum_id = bbp_get_reply_forum_id( $post->ID );
393 $topic_forum_id = bbp_get_topic_forum_id( bbp_get_reply_topic_id( $post->ID ) );
394
395 // Allow individual manipulation of reply forum
396 if ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate' ) ) :
397
398 // Forums
399 $args = array(
400 'selected' => $reply_forum_id,
401 'select_id' => 'bbp_forum_id',
402 'show_none' => __( '(Use Forum of Topic)', 'bbpress' )
403 ); ?>
404
405 <p><strong><?php _e( 'Forum', 'bbpress' ); ?></strong></p>
406
407 <p>
408 <label class="screen-reader-text" for="bbp_forum_id"><?php _e( 'Forum', 'bbpress' ); ?></label>
409
410 <?php bbp_dropdown( $args ); ?>
411
412 </p>
413
414 <?php endif;
415
416 // Topics
417 $args = array(
418 'post_type' => bbp_get_topic_post_type(),
419 'selected' => $reply_topic_id,
420 'select_id' => 'parent_id',
421 'orderby' => 'post_date',
422 'numberposts' => '250',
423 'show_none' => is_super_admin() ? __( '(No Topic)', 'bbpress' ) : '',
424 );
425
426 // Allow the dropdown to be filtered, to extend or limit the available
427 // topics to choose as the reply parent.
428 $args = apply_filters( 'bbp_reply_parent_dropdown', $args ); ?>
429
430 <p><strong><?php _e( 'Topic', 'bbpress' ); ?></strong></p>
431
432 <p>
433 <label class="screen-reader-text" for="parent_id"><?php _e( 'Topic', 'bbpress' ); ?></label>
434
435 <?php bbp_dropdown( $args ); ?>
436
437 </p>
438
439 <?php
440
441 do_action( 'bbp_reply_metabox', $post->ID );
442 }
443
444 /** Users *********************************************************************/
445
446 /**
447 * Anonymous user information metabox
448 *
449 * @since bbPress (r2828)
450 *
451 * @uses bbp_is_reply_anonymous() To check if reply is anonymous
452 * @uses bbp_is_topic_anonymous() To check if topic is anonymous
453 * @uses get_the_ID() To get the global post ID
454 * @uses get_post_meta() To get the author user information
455 */
456 function bbp_author_metabox() {
457
458 // Post ID
459 $post_id = get_the_ID();
460
461 // Show extra bits if topic/reply is anonymous
462 if ( bbp_is_reply_anonymous( $post_id ) || bbp_is_topic_anonymous( $post_id ) ) : ?>
463
464 <p><strong><?php _e( 'Name', 'bbpress' ); ?></strong></p>
465
466 <p>
467 <label class="screen-reader-text" for="bbp_anonymous_name"><?php _e( 'Name', 'bbpress' ); ?></label>
468 <input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php echo get_post_meta( $post_id, '_bbp_anonymous_name', true ); ?>" size="25" />
469 </p>
470
471 <p><strong><?php _e( 'Email', 'bbpress' ); ?></strong></p>
472
473 <p>
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 get_post_meta( $post_id, '_bbp_anonymous_email', true ); ?>" size="25" />
476 </p>
477
478 <p><strong><?php _e( 'Website', 'bbpress' ); ?></strong></p>
479
480 <p>
481 <label class="screen-reader-text" for="bbp_anonymous_website"><?php _e( 'Website', 'bbpress' ); ?></label>
482 <input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php echo get_post_meta( $post_id, '_bbp_anonymous_website', true ); ?>" size="25" />
483 </p>
484
485 <?php endif; ?>
486
487 <p><strong><?php _e( 'IP Address', 'bbpress' ); ?></strong></p>
488
489 <p>
490 <label class="screen-reader-text" for="bbp_author_ip_address"><?php _e( 'IP Address', 'bbpress' ); ?></label>
491 <input type="text" id="bbp_author_ip_address" name="bbp_author_ip_address" value="<?php echo get_post_meta( $post_id, '_bbp_author_ip', true ); ?>" size="25" disabled="disabled" />
492 </p>
493
494 <?php
495
496 do_action( 'bbp_author_metabox', $post_id );
497 }
498
499 ?>
500