Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/13/2017 05:30:47 AM (8 years ago)
Author:
johnjamesjacoby
Message:

Tools: Improvements to repair, upgrade, and converter tools.

  • Use escaped gettext equivalent functions where appropriate
  • Rename description to title so that more descriptive descriptions can be used per-tool in a future version
  • Register all scripts, and properly enqueue them only a needed
  • Reorder & re-title some tools to better match each other
File:
1 edited

Legend:

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

    r6496 r6537  
    2828
    2929    <div class="card">
    30         <h3 class="title"><?php _e( 'Forums', 'bbpress' ) ?></h3>
     30        <h3 class="title"><?php esc_html_e( 'Forums', 'bbpress' ) ?></h3>
    3131        <p><?php esc_html_e( 'bbPress provides the following tools to help you manage your forums:', 'bbpress' ); ?></p>
    3232
     
    4242
    4343            // Add link to array
    44             $links[] = sprintf( '<a href="%s">%s</a>', get_admin_url( '', add_query_arg( array( 'page' => $tool['page'] ), 'tools.php' ) ), $tool['name'] );
     44            $links[] = sprintf( '<a href="%s">%s</a>', esc_url( add_query_arg( array( 'page' => $tool['page'] ), admin_url( 'tools.php' ) ) ), $tool['name'] );
    4545        }
    4646
     
    6767        'id'          => '',
    6868        'type'        => '',
     69        'title'       => '',
    6970        'description' => '',
    7071        'callback'    => '',
     
    7980
    8081    // Bail if missing required values
    81     if ( empty( $r['id'] ) || empty( $r['priority'] ) || empty( $r['description'] ) || empty( $r['callback'] ) ) {
     82    if ( empty( $r['id'] ) || empty( $r['priority'] ) || empty( $r['title'] ) || empty( $r['callback'] ) ) {
    8283        return;
    8384    }
     
    8687    bbpress()->admin->tools[ $r['id'] ] = array(
    8788        'type'        => $r['type'],
     89        'title'       => $r['title'],
    8890        'description' => $r['description'],
    8991        'priority'    => $r['priority'],
     
    109111        'id'          => 'bbp-sync-topic-meta',
    110112        'type'        => 'repair',
    111         'description' => __( 'Recalculate parent topic for each reply', 'bbpress' ),
     113        'title'       => esc_html__( 'Recalculate parent topic for each reply', 'bbpress' ),
    112114        'callback'    => 'bbp_admin_repair_topic_meta',
    113115        'priority'    => 5,
     
    120122        'id'          => 'bbp-sync-forum-meta',
    121123        'type'        => 'repair',
    122         'description' => __( 'Recalculate parent forum for each topic and reply', 'bbpress' ),
     124        'title'       => esc_html__( 'Recalculate parent forum for each topic and reply', 'bbpress' ),
    123125        'callback'    => 'bbp_admin_repair_forum_meta',
    124126        'priority'    => 10,
     
    131133        'id'          => 'bbp-sync-forum-visibility',
    132134        'type'        => 'repair',
    133         'description' => __( 'Recalculate private and hidden forums', 'bbpress' ),
     135        'title'       => esc_html__( 'Recalculate private and hidden forums', 'bbpress' ),
    134136        'callback'    => 'bbp_admin_repair_forum_visibility',
    135137        'priority'    => 15,
     
    142144        'id'          => 'bbp-sync-all-topics-forums',
    143145        'type'        => 'repair',
    144         'description' => __( 'Recalculate last activity in each topic and forum', 'bbpress' ),
     146        'title'       => esc_html__( 'Recalculate last activity in each topic and forum', 'bbpress' ),
    145147        'callback'    => 'bbp_admin_repair_freshness',
    146148        'priority'    => 20,
     
    153155        'id'          => 'bbp-sync-all-topics-sticky',
    154156        'type'        => 'repair',
    155         'description' => __( 'Recalculate sticky relationship of each topic', 'bbpress' ),
     157        'title'       => esc_html__( 'Recalculate sticky relationship of each topic', 'bbpress' ),
    156158        'callback'    => 'bbp_admin_repair_sticky',
    157159        'priority'    => 25,
     
    164166        'id'          => 'bbp-sync-all-reply-positions',
    165167        'type'        => 'repair',
    166         'description' => __( 'Recalculate the position of each reply', 'bbpress' ),
     168        'title'       => esc_html__( 'Recalculate position of each reply in each topic', 'bbpress' ),
    167169        'callback'    => 'bbp_admin_repair_reply_menu_order',
    168170        'priority'    => 30,
     
    171173    ) );
    172174
     175    // Sync all topic engagements for all users
     176    bbp_register_repair_tool( array(
     177        'id'          => 'bbp-topic-engagements',
     178        'type'        => 'repair',
     179        'title'       => esc_html__( 'Recalculate engagements in each topic for each user', 'bbpress' ),
     180        'callback'    => 'bbp_admin_repair_topic_voice_count',
     181        'priority'    => 35,
     182        'overhead'    => 'high',
     183        'components'  => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
     184    ) );
     185
    173186    // Update closed topic counts
    174187    bbp_register_repair_tool( array(
    175188        'id'          => 'bbp-sync-closed-topics',
    176189        'type'        => 'repair',
    177         'description' => __( 'Repair closed topics', 'bbpress' ),
     190        'title'       => esc_html__( 'Repair closed topic statuses', 'bbpress' ),
    178191        'callback'    => 'bbp_admin_repair_closed_topics',
    179         'priority'    => 35,
     192        'priority'    => 40,
    180193        'overhead'    => 'medium',
    181194        'components'  => array( bbp_get_topic_post_type() )
     
    186199        'id'          => 'bbp-forum-topics',
    187200        'type'        => 'repair',
    188         'description' => __( 'Recount topics in each forum', 'bbpress' ),
     201        'title'       => esc_html__( 'Recount topics in each forum', 'bbpress' ),
    189202        'callback'    => 'bbp_admin_repair_forum_topic_count',
    190         'priority'    => 40,
     203        'priority'    => 45,
    191204        'overhead'    => 'medium',
    192205        'components'  => array( bbp_get_forum_post_type(), bbp_get_topic_post_type() )
     
    197210        'id'          => 'bbp-topic-tags',
    198211        'type'        => 'repair',
    199         'description' => __( 'Recount topics in each topic-tag', 'bbpress' ),
     212        'title'       => esc_html__( 'Recount topics in each topic-tag', 'bbpress' ),
    200213        'callback'    => 'bbp_admin_repair_topic_tag_count',
    201         'priority'    => 45,
     214        'priority'    => 50,
    202215        'overhead'    => 'medium',
    203216        'components'  => array( bbp_get_topic_post_type(), bbp_get_topic_tag_tax_id() )
     
    208221        'id'          => 'bbp-forum-replies',
    209222        'type'        => 'repair',
    210         'description' => __( 'Recount replies in each forum', 'bbpress' ),
     223        'title'       => esc_html__( 'Recount replies in each forum', 'bbpress' ),
    211224        'callback'    => 'bbp_admin_repair_forum_reply_count',
    212         'priority'    => 50,
     225        'priority'    => 55,
    213226        'overhead'    => 'high',
    214227        'components'  => array( bbp_get_forum_post_type(), bbp_get_reply_post_type() )
     
    219232        'id'          => 'bbp-topic-replies',
    220233        'type'        => 'repair',
    221         'description' => __( 'Recount replies in each topic', 'bbpress' ),
     234        'title'       => esc_html__( 'Recount replies in each topic', 'bbpress' ),
    222235        'callback'    => 'bbp_admin_repair_topic_reply_count',
    223         'priority'    => 55,
     236        'priority'    => 60,
    224237        'overhead'    => 'high',
    225238        'components'  => array( bbp_get_topic_post_type(), bbp_get_reply_post_type() )
    226239    ) );
    227240
    228     // Count topic engagements
    229     bbp_register_repair_tool( array(
    230         'id'          => 'bbp-topic-engagements',
    231         'type'        => 'repair',
    232         'description' => __( 'Recount engagements in each topic', 'bbpress' ),
    233         'callback'    => 'bbp_admin_repair_topic_voice_count',
    234         'priority'    => 60,
    235         'overhead'    => 'high',
    236         'components'  => array( bbp_get_topic_post_type(), bbp_get_user_rewrite_id() )
    237     ) );
    238 
    239241    // Count non-published replies to each topic
    240242    bbp_register_repair_tool( array(
    241243        'id'          => 'bbp-topic-hidden-replies',
    242244        'type'        => 'repair',
    243         'description' => __( 'Recount pending, spammed, and trashed replies in each topic', 'bbpress' ),
     245        'title'       => esc_html__( 'Recount pending, spammed, and trashed replies in each topic', 'bbpress' ),
    244246        'callback'    => 'bbp_admin_repair_topic_hidden_reply_count',
    245247        'priority'    => 65,
     
    252254        'id'          => 'bbp-user-topics',
    253255        'type'        => 'repair',
    254         'description' => __( 'Recount topics for each user', 'bbpress' ),
     256        'title'       => esc_html__( 'Recount topics for each user', 'bbpress' ),
    255257        'callback'    => 'bbp_admin_repair_user_topic_count',
    256258        'priority'    => 70,
     
    263265        'id'          => 'bbp-user-replies',
    264266        'type'        => 'repair',
    265         'description' => __( 'Recount replies for each user', 'bbpress' ),
     267        'title'       => esc_html__( 'Recount replies for each user', 'bbpress' ),
    266268        'callback'    => 'bbp_admin_repair_user_reply_count',
    267269        'priority'    => 75,
     
    274276        'id'          => 'bbp-user-favorites',
    275277        'type'        => 'repair',
    276         'description' => __( 'Remove unpublished topics from user favorites', 'bbpress' ),
     278        'title'       => esc_html__( 'Remove unpublished topics from user favorites', 'bbpress' ),
    277279        'callback'    => 'bbp_admin_repair_user_favorites',
    278280        'priority'    => 80,
     
    285287        'id'          => 'bbp-user-topic-subscriptions',
    286288        'type'        => 'repair',
    287         'description' => __( 'Remove unpublished topics from user subscriptions', 'bbpress' ),
     289        'title'       => esc_html__( 'Remove unpublished topics from user subscriptions', 'bbpress' ),
    288290        'callback'    => 'bbp_admin_repair_user_topic_subscriptions',
    289291        'priority'    => 85,
     
    296298        'id'          => 'bbp-user-forum-subscriptions',
    297299        'type'        => 'repair',
    298         'description' => __( 'Remove unpublished forums from user subscriptions', 'bbpress' ),
     300        'title'       => esc_html__( 'Remove unpublished forums from user subscriptions', 'bbpress' ),
    299301        'callback'    => 'bbp_admin_repair_user_forum_subscriptions',
    300302        'priority'    => 90,
     
    307309        'id'          => 'bbp-user-role-map',
    308310        'type'        => 'repair',
    309         'description' => __( 'Remap existing users to default forum roles', 'bbpress' ),
     311        'title'       => esc_html__( 'Remap all users to default forum roles', 'bbpress' ),
    310312        'callback'    => 'bbp_admin_repair_user_roles',
    311313        'priority'    => 95,
     
    314316    ) );
    315317
     318    // Migrate topic engagements to post-meta
     319    bbp_register_repair_tool( array(
     320        'id'          => 'bbp-user-topic-engagements-move',
     321        'type'        => 'upgrade',
     322        'title'       => esc_html__( 'Upgrade user topic engagements', 'bbpress' ),
     323        'callback'    => 'bbp_admin_upgrade_user_engagements',
     324        'priority'    => 100,
     325        'overhead'    => 'high',
     326        'components'  => array( bbp_get_user_rewrite_id(), bbp_get_user_engagements_rewrite_id() )
     327    ) );
     328
    316329    // Migrate favorites from user-meta to post-meta
    317330    bbp_register_repair_tool( array(
    318331        'id'          => 'bbp-user-favorites-move',
    319332        'type'        => 'upgrade',
    320         'description' => __( 'Upgrade user favorites', 'bbpress' ),
     333        'title'       => esc_html__( 'Upgrade user topic favorites', 'bbpress' ),
    321334        'callback'    => 'bbp_admin_upgrade_user_favorites',
    322         'priority'    => 100,
     335        'priority'    => 105,
    323336        'overhead'    => 'high',
    324337        'components'  => array( bbp_get_user_rewrite_id(), bbp_get_user_favorites_rewrite_id() )
     
    329342        'id'          => 'bbp-user-topic-subscriptions-move',
    330343        'type'        => 'upgrade',
    331         'description' => __( 'Upgrade user topic subscriptions', 'bbpress' ),
     344        'title'       => esc_html__( 'Upgrade user topic subscriptions', 'bbpress' ),
    332345        'callback'    => 'bbp_admin_upgrade_user_topic_subscriptions',
    333         'priority'    => 105,
     346        'priority'    => 110,
    334347        'overhead'    => 'high',
    335348        'components'  => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
     
    340353        'id'          => 'bbp-user-forum-subscriptions-move',
    341354        'type'        => 'upgrade',
    342         'description' => __( 'Upgrade user forum subscriptions', 'bbpress' ),
     355        'title'       => esc_html__( 'Upgrade user forum subscriptions', 'bbpress' ),
    343356        'callback'    => 'bbp_admin_upgrade_user_forum_subscriptions',
    344         'priority'    => 110,
     357        'priority'    => 115,
    345358        'overhead'    => 'high',
    346359        'components'  => array( bbp_get_user_rewrite_id(), bbp_get_user_subscriptions_rewrite_id() )
    347360    ) );
    348361
    349     // Migrate topic engagements to post-meta
    350     bbp_register_repair_tool( array(
    351         'id'          => 'bbp-user-topic-engagements-move',
    352         'type'        => 'upgrade',
    353         'description' => __( 'Upgrade topic engagements', 'bbpress' ),
    354         'callback'    => 'bbp_admin_upgrade_user_engagements',
    355         'priority'    => 115,
    356         'overhead'    => 'medium',
    357         'components'  => array( bbp_get_user_rewrite_id(), bbp_get_user_engagements_rewrite_id() )
    358     ) );
    359 
    360362    // Sync all BuddyPress group forum relationships
    361363    bbp_register_repair_tool( array(
    362364        'id'          => 'bbp-group-forums',
    363365        'type'        => 'upgrade',
    364         'description' => __( 'Upgrade BuddyPress Group Forum relationships', 'bbpress' ),
     366        'title'       => esc_html__( 'Upgrade BuddyPress Group Forum relationships', 'bbpress' ),
    365367        'callback'    => 'bbp_admin_upgrade_group_forum_relationship',
    366368        'priority'    => 120,
     
    373375        'id'          => 'bbp-user-favorites-delete',
    374376        'type'        => 'upgrade',
    375         'description' => __( 'Remove favorites from user-meta', 'bbpress' ),
     377        'title'       => esc_html__( 'Remove favorites from user-meta', 'bbpress' ),
    376378        'callback'    => 'bbp_admin_upgrade_remove_favorites_from_usermeta',
    377379        'priority'    => 125,
     
    384386        'id'          => 'bbp-user-topic-subscriptions-delete',
    385387        'type'        => 'upgrade',
    386         'description' => __( 'Remove topic subscriptions from user-meta', 'bbpress' ),
     388        'title'       => esc_html__( 'Remove topic subscriptions from user-meta', 'bbpress' ),
    387389        'callback'    => 'bbp_admin_upgrade_remove_topic_subscriptions_from_usermeta',
    388390        'priority'    => 130,
     
    395397        'id'          => 'bbp-user-forum-subscriptions-delete',
    396398        'type'        => 'upgrade',
    397         'description' => __( 'Remove forum subscriptions from user-meta', 'bbpress' ),
     399        'title'       => esc_html__( 'Remove forum subscriptions from user-meta', 'bbpress' ),
    398400        'callback'    => 'bbp_admin_upgrade_remove_forum_subscriptions_from_usermeta',
    399401        'priority'    => 135,
     
    442444            $is_current = (bool) ( $tab['name'] == $active_tab );
    443445            $tab_class  = $is_current ? $active_class : $idle_class;
    444             $tab_url    = get_admin_url( '', add_query_arg( array( 'page' => $tab['page'] ), 'tools.php' ) );
     446            $tab_url    = add_query_arg( array( 'page' => $tab['page'] ), admin_url( 'tools.php' ) );
    445447            $tabs_html .= '<a href="' . esc_url( $tab_url ) . '" class="' . esc_attr( $tab_class ) . '">' . esc_html( $tab['name'] ) . '</a>';
    446448        }
     
    458460 */
    459461function bbp_get_tools_admin_pages() {
     462
     463    // Get tools URL one time & use in each tab
     464    $tools_url = admin_url( 'tools.php' );
    460465
    461466    // Filter & return
     
    468473
    469474            // Deprecated 2.6.0
    470             'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-repair'    ), 'tools.php' ) )
     475            'href' => add_query_arg( array( 'page' => 'bbp-repair' ), $tools_url )
    471476        ),
    472477        array(
     
    477482
    478483            // Deprecated 2.6.0
    479             'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-upgrade' ), 'tools.php' ) )
     484            'href' => add_query_arg( array( 'page' => 'bbp-upgrade' ), $tools_url )
    480485        ),
    481486        array(
     
    486491
    487492            // Deprecated 2.6.0
    488             'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-converter' ), 'tools.php' ) )
     493            'href' => add_query_arg( array( 'page' => 'bbp-converter' ), $tools_url )
    489494        ),
    490495        array(
     
    495500
    496501            // Deprecated 2.6.0
    497             'href' => get_admin_url( '', add_query_arg( array( 'page' => 'bbp-reset'     ), 'tools.php' ) )
     502            'href' => add_query_arg( array( 'page' => 'bbp-reset' ), $tools_url )
    498503        )
    499504    ) );
Note: See TracChangeset for help on using the changeset viewer.