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

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