Skip to:
Content

BuddyPress.org

Changeset 10476


Ignore:
Timestamp:
01/27/2016 09:03:19 PM (4 years ago)
Author:
djpaul
Message:

Emails: add tool to reinstall emails.

This will likely see use on upgrade for non-en_US sites, as the language pack could load after the email posts have already been added to the posts table.

See #6592. Props timersys, mercime, boonebgorges, hnla, DJPaul.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/bp-core-admin-tools.php

    r10439 r10476  
    145145        );
    146146    }
     147
     148    // Emails:
     149    // - reinstall emails.
     150    $repair_list[100] = array(
     151        'bp-reinstall-emails',
     152        __( 'Reinstall emails (delete and restore from defaults).', 'buddypress' ),
     153        'bp_admin_reinstall_emails',
     154    );
    147155
    148156    ksort( $repair_list );
     
    411419    <?php
    412420}
     421
     422/**
     423 * Delete emails and restore from defaults.
     424 *
     425 * @since 2.5.0
     426 *
     427 * @return array
     428 */
     429function bp_admin_reinstall_emails() {
     430    $emails = get_posts( array(
     431        'fields'           => 'ids',
     432        'post_status'      => 'publish',
     433        'post_type'        => bp_get_email_post_type(),
     434        'posts_per_page'   => 200,
     435        'suppress_filters' => false,
     436    ) );
     437
     438    if ( $emails ) {
     439        foreach ( $emails as $email_id ) {
     440            wp_trash_post( $email_id );
     441        }
     442    }
     443
     444    require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
     445    bp_core_install_emails();
     446
     447    return array( 0, __( 'Emails have been successfully reinstalled.', 'buddypress' ) );
     448}
Note: See TracChangeset for help on using the changeset viewer.