Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/23/2017 04:21:58 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Admin/Converter: Lazy load admin & converter as needed.

  • Move admin class into its own file
  • Remove admin.php
  • Introduce _setup_ functions to make loading them on the fly easier
  • Simplify converter logic for smoother starting/stopping
  • Improved UI for timer/status updates
  • Remove double-duty variables from BBP_Converter and response data
  • Switch from text-only response value to JSON object for improved flexibility

This allows the converter to return more data, and makes it easier to work with that data.

Todo:

  • Error responses
  • Check that starts are bumping correctly inside of steps
  • Better utilize JSON responses
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/abstraction.php

    r6583 r6601  
    1616// Exit if accessed directly
    1717defined( 'ABSPATH' ) || exit;
     18
     19/**
     20 * Setup Admin
     21 *
     22 * This exists outside of "/includes/admin/" because the converter may need to
     23 * be setup to convert the passwords of users that were migrated from another
     24 * forum platform.
     25 *
     26 * @since 2.6.0 bbPress (r2596)
     27 */
     28function bbp_setup_admin() {
     29        $bbp = bbpress();
     30
     31        // Skip if already setup
     32        if ( empty( $bbp->admin ) ) {
     33
     34                // Require the admin class
     35                require_once $bbp->includes_dir . 'admin/classes/class-bbp-admin.php';
     36
     37                // Setup
     38                $bbp->admin = class_exists( 'BBP_Admin' )
     39                        ? new BBP_Admin()
     40                        : new stdClass();
     41        }
     42
     43        // Return the admin object
     44        return $bbp->admin;
     45}
     46
     47/**
     48 * Setup Converter
     49 *
     50 * This exists outside of "/includes/admin/" because the converter may need to
     51 * be setup to convert the passwords of users that were migrated from another
     52 * forum platform.
     53 *
     54 * @since 2.6.0 bbPress (r2596)
     55 */
     56function bbp_setup_converter() {
     57        $bbp_admin = bbp_setup_admin();
     58
     59        // Skip if already setup
     60        if ( empty( $bbp_admin->converter ) ) {
     61
     62                // Require the converter classes
     63                require_once $bbp_admin->admin_dir . 'classes/class-bbp-converter-base.php';
     64                require_once $bbp_admin->admin_dir . 'classes/class-bbp-converter.php';
     65
     66                // Setup
     67                $bbp_admin->converter = class_exists( 'BBP_Converter' )
     68                        ? new BBP_Converter()
     69                        : new stdClass();
     70        }
     71
     72        // Return the converter
     73        return $bbp_admin->converter;
     74}
    1875
    1976/**
Note: See TracChangeset for help on using the changeset viewer.