X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fplugin.php;h=9795cacf92019116a439edee50ef28faca5713c3;hb=93143702ed5fe88c0fce77d778d86ec651d4331e;hp=7a4a96670d66a7c953a81b2972b8089aef2b2960;hpb=2cb576d30523088900813d491f3accf9cbbf1857;p=friendica.git diff --git a/include/plugin.php b/include/plugin.php index 7a4a96670d..9795cacf92 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -158,10 +158,16 @@ function load_hooks() { if(! function_exists('call_hooks')) { function call_hooks($name, &$data = null) { + $stamp1 = microtime(true); + $a = get_app(); if((is_array($a->hooks)) && (array_key_exists($name,$a->hooks))) { foreach($a->hooks[$name] as $hook) { + // Don't run a theme's hook if the user isn't using the theme + if(strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/'.current_theme()) === false) + continue; + @include_once($hook[0]); if(function_exists($hook[1])) { $func = $hook[1]; @@ -177,7 +183,6 @@ function call_hooks($name, &$data = null) { } } } - }} @@ -327,6 +332,42 @@ function get_theme_screenshot($theme) { return($a->get_baseurl() . '/images/blank.png'); } +// install and uninstall theme +if (! function_exists('uninstall_theme')){ +function uninstall_theme($theme){ + logger("Addons: uninstalling theme " . $theme); + + @include_once("view/theme/$theme/theme.php"); + if(function_exists("{$theme}_uninstall")) { + $func = "{$theme}_uninstall"; + $func(); + } +}} + +if (! function_exists('install_theme')){ +function install_theme($theme) { + // silently fail if theme was removed + + if(! file_exists("view/theme/$theme/theme.php")) + return false; + + logger("Addons: installing theme $theme"); + + @include_once("view/theme/$theme/theme.php"); + + if(function_exists("{$theme}_install")) { + $func = "{$theme}_install"; + $func(); + return true; + } + else { + logger("Addons: FAILED installing theme $theme"); + return false; + } + +}} + + // check service_class restrictions. If there are no service_classes defined, everything is allowed. // if $usage is supplied, we check against a maximum count and return true if the current usage is