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

(string) (Required) Name of valid platform class.

Source

File: bp-forums/admin/converter.php

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.