Skip to content
Snippets Groups Projects
Commit 13a56a74 authored by George Kiagiadakis's avatar George Kiagiadakis
Browse files

lua: add wp_plugin_find binding

parent c78373b1
No related branches found
No related tags found
No related merge requests found
...@@ -85,6 +85,20 @@ static const luaL_Reg log_funcs[] = { ...@@ -85,6 +85,20 @@ static const luaL_Reg log_funcs[] = {
{ NULL, NULL } { NULL, NULL }
}; };
/* WpPlugin */
static int
plugin_find (lua_State *L)
{
const char *name = luaL_checkstring (L, 1);
WpPlugin *plugin = wp_plugin_find (get_wp_core (L), name);
if (plugin)
wplua_pushobject (L, plugin);
else
lua_pushnil (L);
return 1;
}
/* WpObject */ /* WpObject */
static void static void
...@@ -791,6 +805,9 @@ wp_lua_scripting_api_init (lua_State *L) ...@@ -791,6 +805,9 @@ wp_lua_scripting_api_init (lua_State *L)
luaL_newlib (L, log_funcs); luaL_newlib (L, log_funcs);
lua_setglobal (L, "WpDebug"); lua_setglobal (L, "WpDebug");
lua_pushcfunction (L, plugin_find);
lua_setglobal (L, "WpPlugin_find");
wplua_register_type_methods (L, WP_TYPE_OBJECT, wplua_register_type_methods (L, WP_TYPE_OBJECT,
NULL, object_methods); NULL, object_methods);
wplua_register_type_methods (L, WP_TYPE_GLOBAL_PROXY, wplua_register_type_methods (L, WP_TYPE_GLOBAL_PROXY,
......
...@@ -110,6 +110,7 @@ SANDBOX_EXPORT = { ...@@ -110,6 +110,7 @@ SANDBOX_EXPORT = {
Features = Features, Features = Features,
Feature = Feature, Feature = Feature,
Log = WpDebug, Log = WpDebug,
Plugin = WpPlugin_find,
ObjectManager = WpObjectManager_new, ObjectManager = WpObjectManager_new,
Interest = WpObjectInterest_new, Interest = WpObjectInterest_new,
SessionItem = WpSessionItem_new, SessionItem = WpSessionItem_new,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment