From 42d13b904c840cceda511c0ac759d549cd1b7a19 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 9 Feb 2017 09:37:16 +0100 Subject: [PATCH] plugins: allow to search for a plugin withing plugins_scan() PR: https://github.com/opnsense/core/pull/1388 --- src/etc/inc/plugins.inc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/plugins.inc b/src/etc/inc/plugins.inc index 3e40da54a..4c77b5c65 100644 --- a/src/etc/inc/plugins.inc +++ b/src/etc/inc/plugins.inc @@ -1,7 +1,7 @@ + * Copyright (C) 2016-2017 Franco Fichtner * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,7 +30,7 @@ * scan plugins for legacy system * @return array */ -function plugins_scan() +function plugins_scan($search = '') { $path = '/usr/local/etc/inc/plugins.inc.d/'; $ext = '.inc'; @@ -47,6 +47,9 @@ function plugins_scan() foreach ($plugins as $plugin) { $name = preg_replace('/' . preg_quote($path, '/') . '/', '', $plugin); $name = preg_replace('/' . preg_quote($ext, '/') . '/', '', $name); + if (!empty($search) && $search !== $name) { + continue; + } $ret[$name] = $plugin; }