class-foo-bar.php, searching includes/ then admin/. */ spl_autoload_register( static function ( $class_name ) { if ( 0 !== strpos( $class_name, 'Oorank_' ) ) { return; } $slug = substr( $class_name, strlen( 'Oorank_' ) ); $slug = strtolower( str_replace( '_', '-', $slug ) ); $file = 'class-' . $slug . '.php'; foreach ( array( 'includes/', 'admin/' ) as $dir ) { $path = OORANK_PATH . $dir . $file; if ( is_readable( $path ) ) { require_once $path; return; } } } ); /** * Filesystem path of the public site root, with a trailing slash. * * Files served from the site root — robots.txt, llms.txt — live where the home * URL points, which is not ABSPATH when WordPress is installed in its own * subdirectory. get_home_path() is the only function that resolves that, and it * ships in an admin file that is not loaded on every request. * * @return string Absolute path to the site root, trailing-slashed. */ function oorank_home_path() { if ( ! function_exists( 'get_home_path' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } return trailingslashit( get_home_path() ); } register_activation_hook( __FILE__, array( 'Oorank_Plugin', 'activate' ) ); register_deactivation_hook( __FILE__, array( 'Oorank_Plugin', 'deactivate' ) ); /** * Boot the plugin. * * @return Oorank_Plugin */ function oorank() { return Oorank_Plugin::instance(); } oorank()->run();