Esempio n. 1
0
/**
 * Handle the processing and feedback of the admin tools page
 *
 * @since bbPress (r2613)
 *
 * @uses bbp_admin_repair_list() To get the recount list
 * @uses check_admin_referer() To verify the nonce and the referer
 * @uses wp_cache_flush() To flush the cache
 * @uses do_action() Calls 'admin_notices' to display the notices
 */
function bbp_admin_repair_handler()
{
    if (!bbp_is_post_request()) {
        return;
    }
    check_admin_referer('bbpress-do-counts');
    // Stores messages
    $messages = array();
    wp_cache_flush();
    foreach ((array) bbp_admin_repair_list() as $item) {
        if (isset($item[2]) && isset($_POST[$item[0]]) && 1 === absint($_POST[$item[0]]) && is_callable($item[2])) {
            $messages[] = call_user_func($item[2]);
        }
    }
    if (count($messages)) {
        foreach ($messages as $message) {
            bbp_admin_tools_feedback($message[1]);
        }
    }
}
Esempio n. 2
0
/**
 * Admin repair page
 *
 * @since 2.0.0 bbPress (r2613) Converted from bbPress 1.2
 * @since 2.6.0 bbPress (r5885) Upgraded to list-table UI
 *
 * @todo Use a real list table
 *
 * @uses bbp_admin_repair_list() To get the recount list
 * @uses check_admin_referer() To verify the nonce and the referer
 * @uses wp_cache_flush() To flush the cache
 * @uses do_action() Calls 'admin_notices' to display the notices
 * @uses wp_nonce_field() To add a hidden nonce field
 */
function bbp_admin_repair()
{
    // Get the registered repair tools
    $tools = bbp_admin_repair_list();
    ?>

	<div class="wrap">
		<h1><?php 
    esc_html_e('Forum Tools', 'bbpress');
    ?>
</h1>
		<h2 class="nav-tab-wrapper"><?php 
    bbp_tools_admin_tabs(__('Repair Forums', 'bbpress'));
    ?>
</h2>

		<p><?php 
    esc_html_e('bbPress keeps track of relationships between forums, topics, replies, and topic tags, and users. Occasionally these relationships become out of sync, most often after an import or migration. Use the tools below to manually recalculate these relationships.', 'bbpress');
    ?>
</p>
		<p class="description"><?php 
    esc_html_e('Some of these tools create substantial database overhead. Use caution when running more than 1 repair at a time.', 'bbpress');
    ?>
</p>

		<?php 
    bbp_admin_repair_tool_overhead_filters();
    ?>

		<form class="settings" method="get" action="">

			<?php 
    bbp_admin_repair_list_search_form();
    ?>

			<input type="hidden" name="page" value="bbp-repair" />
			<?php 
    wp_nonce_field('bbpress-do-counts');
    ?>

			<div class="tablenav top">
				<div class="alignleft actions bulkactions">
					<label for="bulk-action-selector-top" class="screen-reader-text"><?php 
    esc_html_e('Select bulk action', 'bbpress');
    ?>
</label>
					<select name="action" id="bulk-action-selector-top">
						<option value="" selected="selected"><?php 
    esc_html_e('Bulk Actions', 'bbpress');
    ?>
</option>
						<option value="run" class="hide-if-no-js"><?php 
    esc_html_e('Run', 'bbpress');
    ?>
</option>
					</select>
					<input type="submit" id="doaction" class="button action" value="<?php 
    esc_attr_e('Apply', 'bbpress');
    ?>
">
				</div>
				<div class="alignleft actions">

					<?php 
    bbp_admin_repair_list_components_filter();
    ?>

				</div>
				<br class="clear">
			</div>
			<table class="wp-list-table widefat striped posts">
				<thead>
					<tr>
						<td id="cb" class="manage-column column-cb check-column">
							<label class="screen-reader-text" for="cb-select-all-1">
								<?php 
    esc_html_e('Select All', 'bbpress');
    ?>
							</label>
							<input id="cb-select-all-1" type="checkbox">
						</td>
						<th scope="col" id="description" class="manage-column column-description"><?php 
    esc_html_e('Description', 'bbpress');
    ?>
</th>
						<th scope="col" id="components" class="manage-column column-components"><?php 
    esc_html_e('Components', 'bbpress');
    ?>
</th>
						<th scope="col" id="overhead" class="manage-column column-overhead"><?php 
    esc_html_e('Overhead', 'bbpress');
    ?>
</th>
					</tr>
				</thead>

				<tbody id="the-list">

					<?php 
    if (!empty($tools)) {
        ?>

						<?php 
        foreach ($tools as $item) {
            ?>

							<tr id="bbp-repair-tools" class="inactive">
								<th scope="row" class="check-column">
									<label class="screen-reader-text" for="<?php 
            echo esc_attr(str_replace('_', '-', $item['id']));
            ?>
"></label>
									<input type="checkbox" name="checked[]" value="<?php 
            echo esc_attr($item['id']);
            ?>
" id="<?php 
            echo esc_attr(str_replace('_', '-', $item['id']));
            ?>
">
								</th>
								<td class="bbp-tool-title column-primary">
									<strong><?php 
            echo esc_html($item['description']);
            ?>
</strong>
									<div class="row-actions hide-if-no-js">
										<span class="run">
											<a href="<?php 
            bbp_admin_repair_tool_run_url($item['id']);
            ?>
" aria-label="<?php 
            printf(esc_html__('Run %s', 'bbpress'), $item['description']);
            ?>
" id="<?php 
            echo esc_attr($item['id']);
            ?>
" ><?php 
            esc_html_e('Run', 'bbpress');
            ?>
</a>
										</span>
									</div>
									<button type="button" class="toggle-row">
										<span class="screen-reader-text"><?php 
            esc_html_e('Show more details', 'bbpress');
            ?>
</span>
									</button>
								</td>
								<td class="column-components desc">
									<div class="bbp-tool-overhead">

										<?php 
            echo implode(', ', bbp_get_admin_repair_tool_components($item));
            ?>

									</div>
								</td>
								<td class="column-overhead desc">
									<div class="bbp-tool-overhead">

										<?php 
            echo esc_html($item['overhead']);
            ?>

									</div>
								</td>
							</tr>

						<?php 
        }
        ?>

					<?php 
    } else {
        ?>

						<tr>
							<td colspan="4">
								<?php 
        esc_html_e('No repair tools match this criteria.', 'bbpress');
        ?>
							</td>
						</tr>

					<?php 
    }
    ?>

				</tbody>
				<tfoot>
					<tr>
						<td class="manage-column column-cb check-column">
							<label class="screen-reader-text" for="cb-select-all-2">
								<?php 
    esc_html_e('Select All', 'bbpress');
    ?>
							</label>
							<input id="cb-select-all-2" type="checkbox">
						</td>
						<th scope="col" class="manage-column column-description"><?php 
    esc_html_e('Description', 'bbpress');
    ?>
</th>
						<th scope="col" class="manage-column column-components"><?php 
    esc_html_e('Components', 'bbpress');
    ?>
</th>
						<th scope="col" class="manage-column column-overhead"><?php 
    esc_html_e('Overhead', 'bbpress');
    ?>
</th>
					</tr>
				</tfoot>
			</table>
			<div class="tablenav bottom">
				<div class="alignleft actions bulkactions">
					<label for="bulk-action-selector-bottom" class="screen-reader-text"><?php 
    esc_html_e('Select bulk action', 'bbpress');
    ?>
</label>
					<select name="action2" id="bulk-action-selector-bottom">
						<option value="" selected="selected"><?php 
    esc_html_e('Bulk Actions', 'bbpress');
    ?>
</option>
						<option value="run" class="hide-if-no-js"><?php 
    esc_html_e('Run', 'bbpress');
    ?>
</option>
					</select>
					<input type="submit" id="doaction2" class="button action" value="<?php 
    esc_attr_e('Apply', 'bbpress');
    ?>
">
				</div>
			</div>
		</form>
	</div>

<?php 
}
Esempio n. 3
0
/**
 * Handle the processing and feedback of the admin tools page
 *
 * @since bbPress (r2613)
 *
 * @uses bbp_admin_repair_list() To get the recount list
 * @uses check_admin_referer() To verify the nonce and the referer
 * @uses wp_cache_flush() To flush the cache
 * @uses do_action() Calls 'admin_notices' to display the notices
 */
function bbp_admin_repair_handler()
{
    if ('post' == strtolower($_SERVER['REQUEST_METHOD'])) {
        check_admin_referer('bbpress-do-counts');
        // Stores messages
        $messages = array();
        wp_cache_flush();
        foreach ((array) bbp_admin_repair_list() as $item) {
            if (isset($item[2]) && isset($_POST[$item[0]]) && 1 == $_POST[$item[0]] && is_callable($item[2])) {
                $messages[] = call_user_func($item[2]);
            }
        }
        if (count($messages)) {
            foreach ($messages as $message) {
                bbp_admin_tools_feedback($message[1]);
            }
        }
    }
}