cotonti.com : idea: Optimize plugin hook includes https://www.cotonti.com Laatste forum onderwerpen Cotonti en Sun, 28 Dec 2025 00:56:11 -0000 ez I still work a lot in Genoa.... so I am always looking for improvements there....

Sienna ( I am not sure about that yet )... I see a lot off good things, but i doubt some off them... (Not all changes... I think are real improvements)
So I am really wondering where Sienna is going.

What I really would have liked is more good plugins rather then a core rewrite... I would have loved a more gradual core change.

But hey.... its just my thoughts..
 


 

]]>
Ma, 05 Dec 2011 18:15:45 -0000
Twiebie #31905 esclkm:

you want to rewrite all genoa pluugs?

I wouldn't mind it if you did :)

]]>
Ma, 05 Dec 2011 18:04:27 -0000
esclkm you want to rewrite all genoa pluugs?

]]>
Ma, 05 Dec 2011 16:18:34 -0000
ez Ow.. ok i get it.... forget this post.. it does not work due to wrong variable scope

]]>
Ma, 05 Dec 2011 16:13:01 -0000
esclkm try to use vaiables in your code))) no way?

]]>
Ma, 05 Dec 2011 13:44:43 -0000
ez @esclkm:
Could you explain more about why this is a bad idea.... ???
 

]]>
Ma, 05 Dec 2011 13:07:58 -0000
esclkm include in funtion is very bad Idea - We try in in cotonti 0.7 - but it need to use $_GLOBAL for using variables

So in siena this code optimized

]]>
Ma, 05 Dec 2011 13:00:51 -0000
ez To activate the code from a hook, we always do something like this:

/* === Hook === */
$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

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.

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;
				// the above line CAN be optional if the return data is needed ????
				include_once($cfg['plugins_dir'].'/'.$k['pl_code'].'/'.$k['pl_file'].'.php');
			}
		}
	}
	return $extplugins;
}

 

Result:

And the call to activate hook includes is just:

/* === Hook === */
$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

]]>
Ma, 05 Dec 2011 12:56:53 -0000