You appear to be a bot. Output may be restricted
Description
Check the existence of the available libraries for the given pluginA plugin may say that it offers a set of libraries but that doesn't guarantee that the library file exists. This routine checks for the existence of the source file before it's added to the array of libraries. It doesn't check for the dependencies.
Usage
$array = oik_lib_check_libs( $libraries, $libs, $plugin );
Parameters
- $libraries
- ( array ) required – array of registered libraries
- $libs
- ( array ) required – array of libraries to add in form "library" => "dependencies"
- $plugin
- ( string ) required – plugin slug
Returns
array the updated libraries arrayTO DO
Note: This may be inefficient. There may be libraries that are hardly ever requested It would be better if we defer the file_exists() logic until the library is actually requested. Similarly, we may defer the building of $src… which would require setting a "plugin" or "theme" parameter and possibly a "libs" path.Source
File name: oik-libs/libs/oik-lib.phpLines:
1 to 16 of 16
function oik_lib_check_libs( $libraries, $libs, $plugin ) { $lib_args = array(); foreach ( $libs as $library => $depends ) { $src = oik_path( "libs/$library.php", $plugin ); if ( file_exists( $src ) ) { $lib_args['library'] = $library; $lib_args['src'] = $src; $lib_args['deps'] = $depends; $lib = new OIK_lib( $lib_args ); $libraries[] = $lib; } else { bw_log( $src, "$plugin does not deliver $library file in $src", false ); } } return( $libraries ); }View on GitHub