To activate the code from a hook, we always do something like this:
PHP
1
2
3
4
5
6
7
8
9
10
$extp
= sed_getextplugins(
'input'
);
if
(
is_array
(
$extp
))
{
foreach
(
$extp
as
$k
=>
$pl
)
{
include_once
(
$cfg
[
'plugins_dir'
].
'/'
.
$pl
[
'pl_code'
].
'/'
.
$pl
[
'pl_file'
].
'.php'
);
}
}
The function sed_getextplugins itself gets off course the hooks
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function
sed_getextplugins(
$hook
,
$cond
=
'R'
)
{
global
$sed_plugins
,
$usr
;
if
(
is_array
(
$sed_plugins
))
{
foreach
(
$sed_plugins
as
$i
=>
$k
)
{
if
(
$k
[
'pl_hook'
]==
$hook
&& sed_auth(
'plug'
,
$k
[
'pl_code'
],
$cond
))
{
$extplugins
[
$i
] =
$k
;
}
}
}
return
$extplugins
;
}
THE IDEA to speed things up (and this is a just a quick idea i got) to integrate these two parts together in a
new function in functions.php.
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function
sed_getextplugins_hook_includecode(
$hook
,
$cond
=
'R'
)
{
global
$sed_plugins
,
$usr
,
$cfg
;
if
(
is_array
(
$sed_plugins
))
{
foreach
(
$sed_plugins
as
$i
=>
$k
)
{
if
(
$k
[
'pl_hook'
]==
$hook
&& sed_auth(
'plug'
,
$k
[
'pl_code'
],
$cond
))
{
$extplugins
[
$i
] =
$k
;
include_once
(
$cfg
[
'plugins_dir'
].
'/'
.
$k
[
'pl_code'
].
'/'
.
$k
[
'pl_file'
].
'.php'
);
}
}
}
return
$extplugins
;
}
Result:
And the call to activate hook includes is just:
PHP
1
2
3
$extp
= sed_getextplugins_hook_includecode(
'input'
);
This could save a couple off calls and possible foreach loops. Also the new code looks better :)
I am an optimizing freak... so i always look different @ the code
greetings,
EZ