PluginProbe
bbPress / 2.0.2
bbPress v2.0.2
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 2.2.2 All 71 releases
bbpress / bbp-admin / bbp-tools.php

bbp-tools.php in bbPress 2.0.2, at bbp-admin/bbp-tools.php

98 lines 2.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 Tools Page
5 *
6 * @package bbPress
7 * @subpackage Administration
8 */
9
10 // Exit if accessed directly
11 if ( !defined( 'ABSPATH' ) ) exit;
12
13 /**
14 * Admin tools page
15 *
16 * @since bbPress (r2613)
17 *
18 * @uses bbp_recount_list() To get the recount list
19 * @uses check_admin_referer() To verify the nonce and the referer
20 * @uses wp_cache_flush() To flush the cache
21 * @uses do_action() Calls 'admin_notices' to display the notices
22 * @uses screen_icon() To display the screen icon
23 * @uses wp_nonce_field() To add a hidden nonce field
24 */
25 function bbp_admin_tools() {
26
27 $recount_list = bbp_recount_list();
28
29 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {
30 check_admin_referer( 'do-counts' );
31
32 // Stores messages
33 $messages = array();
34
35 wp_cache_flush();
36
37 foreach ( (array) $recount_list as $item )
38 if ( isset( $item[2] ) && isset( $_POST[$item[0]] ) && 1 == $_POST[$item[0]] && is_callable( $item[2] ) )
39 $messages[] = call_user_func( $item[2] );
40
41
42 if ( count( $messages ) ) {
43 foreach ( $messages as $message ) {
44 bbp_admin_notices( $message[1] );
45 }
46 }
47 } ?>
48
49 <div class="wrap">
50
51 <?php screen_icon( 'tools' ); ?>
52
53 <h2><?php _e( 'bbPress Recount', 'bbpress' ) ?></h2>
54
55 <?php do_action( 'admin_notices' ); ?>
56
57 <p><?php _e( 'bbPress keeps a running count of things like replies to each topic and topics in each forum. In rare occasions these counts can fall out of sync. Using this form you can have bbPress manually recount these items.', 'bbpress' ); ?></p>
58 <p><?php _e( 'You can also use this form to clean out stale items like empty tags.', 'bbpress' ); ?></p>
59
60 <form class="settings" method="post" action="">
61 <table class="form-table">
62 <tbody>
63 <tr valign="top">
64 <th scope="row"><?php _e( 'Things to recount:', 'bbpress' ) ?></th>
65 <td>
66 <fieldset>
67 <legend class="screen-reader-text"><span><?php _e( 'Recount', 'bbpress' ) ?></span></legend>
68
69 <?php if ( !empty( $recount_list ) ) :
70
71 foreach ( $recount_list as $item ) {
72 echo '<label><input type="checkbox" class="checkbox" name="' . esc_attr( $item[0] ) . '" id="' . esc_attr( str_replace( '_', '-', $item[0] ) ) . '" value="1" /> ' . esc_html( $item[1] ) . '</label><br />' . "\n";
73 }
74 ?>
75
76 <?php else : ?>
77
78 <p><?php _e( 'There are no recount tools available.', 'bbpress' ) ?></p>
79
80 <?php endif; ?>
81
82 </fieldset>
83 </td>
84 </tr>
85 </tbody>
86 </table>
87
88 <fieldset class="submit">
89 <input class="button-primary" type="submit" name="submit" value="<?php _e( 'Recount Items', 'bbpress' ); ?>" />
90 <?php wp_nonce_field( 'do-counts' ); ?>
91 </fieldset>
92 </form>
93 </div>
94
95 <?php
96 }
97 ?>
98