Changeset 6785 for trunk/src/includes/admin/tools/converter.php
- Timestamp:
- 02/19/2018 07:00:55 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/tools/converter.php
r6601 r6785 21 21 */ 22 22 function bbp_get_converters() { 23 static $files = array(); 23 24 24 // Default 25 $files = array(); 26 $path = bbp_setup_converter()->converters_dir; 27 $curdir = opendir( $path ); 25 // Only hit the file system one time per page load 26 if ( empty( $files ) ) { 28 27 29 // Look for the converter file in the converters directory 30 if ( false !== $curdir ) { 31 while ( $file = readdir( $curdir ) ) { 32 if ( stristr( $file, '.php' ) && stristr( $file, 'index' ) === false ) { 33 $name = preg_replace( '/.php/', '', $file ); 34 if ( 'Example' !== $name ) { 35 $files[ $name ] = $path . $file; 28 // Open the converter directory 29 $path = bbp_setup_converter()->converters_dir; 30 $curdir = opendir( $path ); 31 32 // Look for the converter file in the converters directory 33 if ( false !== $curdir ) { 34 while ( $file = readdir( $curdir ) ) { 35 if ( stristr( $file, '.php' ) && stristr( $file, 'index' ) === false ) { 36 $name = preg_replace( '/.php/', '', $file ); 37 if ( 'Example' !== $name ) { 38 $files[ $name ] = $path . $file; 39 } 36 40 } 37 41 } 38 42 } 39 }40 43 41 // Close the directory42 closedir( $curdir );44 // Close the directory 45 closedir( $curdir ); 43 46 44 // Sort keys alphabetically, ignoring upper/lower casing 45 if ( ! empty( $files ) ) { 46 natcasesort( $files ); 47 // Sort keys alphabetically, ignoring upper/lower casing 48 if ( ! empty( $files ) ) { 49 natcasesort( $files ); 50 } 47 51 } 48 52 … … 60 64 * @param string $platform Name of valid platform class. 61 65 */ 62 function bbp_new_converter( $platform ) {66 function bbp_new_converter( $platform = '' ) { 63 67 64 // Default value65 $converters = bbp_get_converters();68 // Bail if no platform 69 if ( ! empty( $platform ) ) { 66 70 67 // Create a new converter object if it's found68 if ( isset( $converters[ $platform ] ) ) {71 // Get the available converters 72 $converters = bbp_get_converters(); 69 73 70 // Include & create the converter 71 require_once $converters[ $platform ]; 72 if ( class_exists( $platform ) ) { 73 return new $platform; 74 // Create a new converter object if it's found 75 if ( isset( $converters[ $platform ] ) ) { 76 77 // Include & create the converter 78 require_once $converters[ $platform ]; 79 if ( class_exists( $platform ) ) { 80 return new $platform; 81 } 74 82 } 75 83 }
Note: See TracChangeset
for help on using the changeset viewer.