bbp_new_converter( string $platform )

This is a function that is purposely written to look like a “new” statement.

Description

It is basically a dynamic loader that will load in the platform conversion of your choice.

Parameters

$platform

(Required) Name of valid platform class.

Source

File: bp-forums/admin/converter.php

1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
function bbp_new_converter( $platform ) {
    $found = false;
 
    if ( $curdir = opendir( bbpress()->admin->admin_dir . 'converters/' ) ) {
        while ( $file = readdir( $curdir ) ) {
            if ( stristr( $file, '.php' ) && stristr( $file, 'index' ) === FALSE ) {
                $file = preg_replace( '/.php/', '', $file );
                if ( $platform == $file ) {
                    $found = true;
                    continue;
                }
            }
        }
        closedir( $curdir );
    }
 
    if ( true === $found ) {
        require_once( bbpress()->admin->admin_dir . 'converters/' . $platform . '.php' );
        return new $platform;
    } else {
        return null;
    }
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.