Skip to:
Content

bbPress.org

Changeset 6934


Ignore:
Timestamp:
11/12/2019 05:12:14 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Tools: allow repairs to also be pending.

This commit makes Repairs work like Upgrades, allowing for repair tools to also be pending. It adds a $type parameter to a few functions to allow grouping or separating, depending on the count context.

See #3052.

Location:
trunk/src/includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/tools.php

    r6925 r6934  
    521521            'func' => 'bbp_admin_repair_page',
    522522            'cap'  => 'bbp_tools_repair_page',
    523             'name' => esc_html__( 'Repair Forums', 'bbpress' ),
     523            'name' => bbp_maybe_append_pending_upgrade_count( esc_html__( 'Repair Forums', 'bbpress' ), 'repair' ),
    524524
    525525            // Deprecated 2.6.0
     
    530530            'func' => 'bbp_admin_upgrade_page',
    531531            'cap'  => 'bbp_tools_upgrade_page',
    532             'name' => bbp_maybe_append_pending_upgrade_count( esc_html__( 'Upgrade Forums', 'bbpress' ) ),
     532            'name' => bbp_maybe_append_pending_upgrade_count( esc_html__( 'Upgrade Forums', 'bbpress' ), 'upgrade' ),
    533533
    534534            // Deprecated 2.6.0
  • trunk/src/includes/admin/tools/common.php

    r6933 r6934  
    881881    }
    882882
     883    // Get the type of tool
     884    $type = bbp_get_admin_repair_tool_page_id();
     885
    883886    // Count the tools
    884     $tools = bbp_get_admin_repair_tools( bbp_get_admin_repair_tool_page_id() );
     887    $tools = bbp_get_admin_repair_tools( $type );
    885888
    886889    // Get the tools URL
     
    888891
    889892    // Get pending upgrades
    890     $pending = bbp_get_pending_upgrades();
     893    $pending = bbp_get_pending_upgrades( $type );
    891894
    892895    // Get the current status, if any
  • trunk/src/includes/admin/tools/repair.php

    r6933 r6934  
    4848        <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>
    4949
    50         <?php bbp_admin_repair_tool_overhead_filters(); ?>
     50        <?php bbp_admin_repair_tool_status_filters(); ?>
    5151
    5252        <form class="settings" method="get" action="">
  • trunk/src/includes/core/update.php

    r6926 r6934  
    501501 * @since 2.6.0 bbPress (r6895)
    502502 *
     503 * @param string $type Type of pending upgrades (upgrade|repair|empty)
     504 *
    503505 * @return int
    504506 */
    505 function bbp_get_pending_upgrade_count() {
    506     return count( (array) bbp_get_pending_upgrades() );
     507function bbp_get_pending_upgrade_count( $type = '' ) {
     508    return count( (array) bbp_get_pending_upgrades( $type ) );
    507509}
    508510
     
    512514 * @since 2.6.0 bbPress (r6895)
    513515 *
     516 * @param string $type Type of pending upgrades (upgrade|repair|empty)
     517 *
    514518 * @return array
    515519 */
    516 function bbp_get_pending_upgrades() {
    517     return (array) get_option( '_bbp_db_pending_upgrades', array() );
     520function bbp_get_pending_upgrades( $type = '' ) {
     521
     522    // Get the pending upgrades
     523    $retval = (array) get_option( '_bbp_db_pending_upgrades', array() );
     524
     525    // Looking for a specific type?
     526    if ( ! empty( $type ) ) {
     527        $tools   = bbp_get_admin_repair_tools( $type );
     528        $plucked = array_keys( wp_list_pluck( $tools, 'type' ) );
     529        $retval  = array_intersect( $retval, $plucked );
     530    }
     531
     532    return (array) $retval;
    518533}
    519534
     
    577592 * @since 2.6.0 bbPress (r6896)
    578593 *
    579  * @param string $string
     594 * @param string $string Text to append count to
     595 * @param string $type   Type of pending upgrades (upgrade|repair|empty)
    580596 *
    581597 * @return string
    582598 */
    583 function bbp_maybe_append_pending_upgrade_count( $string = '' ) {
     599function bbp_maybe_append_pending_upgrade_count( $string = '', $type = '' ) {
    584600
    585601    // Look for an upgrade count
    586     $count = bbp_get_pending_upgrade_count();
     602    $count = bbp_get_pending_upgrade_count( $type );
    587603
    588604    // Append the count to the string
Note: See TracChangeset for help on using the changeset viewer.