/** * Add admin when 'oik' OR 'oik-lib' is active * * What if it's been done already? * oik-fum is dependent upon its own library ( oik_fum ) and the * shared libraries that the oik base plugin used. * If oik-lib is active then we can simply request "oik_fum" * If not, we have to request them one by one. * * @TODO We can tell oik-lib is active by ??? * */ function oikf_admin_setup() { oik_lib_fallback(__DIR__ . "/vendor/bobbingwide/oik_fum"); $bobbfunc = oik_require_lib("bobbfunc"); //c( $bobbfunc ); $bobbforms = oik_require_lib("bobbforms"); //c( $bobbforms ); $oik_admin = oik_require_lib("oik-admin"); //c( $oik_admin ); $oik_fum = oik_require_lib("oik_fum"); //c( $oik_fum ); bw_trace2($oik_fum, "oik_fum library?", false, BW_TRACE_DEBUG); if ($oik_fum && !is_wp_error($oik_fum)) { $oik_fum_admin = oik_require_file('admin/oik-fum.php', "oik_fum"); bw_trace2($oik_fum_admin, "oik_fum_admin?", false, BW_TRACE_DEBUG); //c( $oik_fum_admin ); //echo $oik_fum_admin; if ($oik_fum_admin) { oik_fum_add_page(); } } }
/** * */ function bootstrap_oik_libs() { $loaded = false; if (function_exists("oik_require_lib")) { $loaded = true; } else { require_once __DIR__ . "/oik_boot.php"; $loaded = true; } if ($loaded && function_exists("oik_lib_fallback")) { oik_lib_fallback(__DIR__); oik_init(); } //echo "Loaded!"; //print_r( get_included_files() ); return $loaded; }
/** * Functions to invoke when loaded * * Just about everything that needs to be done should be done by the _oik-lib-mu plugin * so we don't need to do anything except when being activated / deactivated * * Given that we don't do anything much we might as well let ourselves become deactivated. * In which case, we should have / share an option field to record the state of play. * One of the values will be "Always load MU libraries" * * This can also be used by the _oik-lib-mu plugin to * decide which library files should be loaded, regardless of the state of the plugins which deliver them. * * So we only need to do anything when we're processing "admin" stuff * */ function oik_lib_loaded() { if (oik_lib_boot_oik_lib()) { bw_trace2("oik_lib_boot_oik_lib worked", null, false, BW_TRACE_DEBUG); add_filter("oik_query_libs", "oik_lib_oik_query_libs", 11); add_action("admin_menu", "oik_lib_admin_menu"); oik_lib_fallback(__DIR__ . "/libs"); add_action("init", "oik_lib_init"); add_action("plugins_loaded", "oik_lib_reset_libs"); add_action("wp_loaded", "oik_lib_wp_loaded"); } else { gob(); } }
function oik_require_lib_fallback($library) { if (false === strpos($library, ".php")) { $library .= ".php"; } $oik_lib_fallback = oik_lib_fallback(__DIR__); foreach ($oik_lib_fallback as $library_dir) { $library_file = "{$library_dir}/{$library}"; //echo "<b>trying: $library_file</b>" . PHP_EOL; if (file_exists($library_file)) { require_once $library_file; break; } else { $library_file = false; } } return $library_file; }