X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fplugin.php;h=ef0ddd05ef108c41c482b2b365ac970cd79c85fb;hb=c273adf0fe21f9e675ba0598ba6b748ad0b41517;hp=3eeb0ccaa8c1097f4104c2e6da579af58c77d46d;hpb=250c6150583389087ecfcfccd0c0f7762c27c6cf;p=friendica.git diff --git a/include/plugin.php b/include/plugin.php index 3eeb0ccaa8..ef0ddd05ef 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -9,9 +9,6 @@ function uninstall_plugin($plugin){ dbesc($plugin) ); - // define THISPLUGIN, make life easy to plugin devs :-) - define("THISPLUGIN", 'addon/' . $plugin . '/' . $plugin . '.php'); - @include_once('addon/' . $plugin . '/' . $plugin . '.php'); if(function_exists($plugin . '_uninstall')) { $func = $plugin . '_uninstall'; @@ -23,9 +20,6 @@ if (! function_exists('install_plugin')){ function install_plugin($plugin) { // silently fail if plugin was removed - // define THISPLUGIN, make life easy to plugin devs :-) - define("THISPLUGIN", 'addon/' . $plugin . '/' . $plugin . '.php'); - if(! file_exists('addon/' . $plugin . '/' . $plugin . '.php')) return false; logger("Addons: installing " . $plugin); @@ -83,9 +77,6 @@ function reload_plugins() { $fname = 'addon/' . $pl . '/' . $pl . '.php'; - // define THISPLUGIN, make life easy to plugin devs :-) - define("THISPLUGIN", $fname); - if(file_exists($fname)) { $t = @filemtime($fname); foreach($installed as $i) { @@ -171,8 +162,10 @@ function call_hooks($name, &$data = null) { if((is_array($a->hooks)) && (array_key_exists($name,$a->hooks))) { foreach($a->hooks[$name] as $hook) { - // define THISPLUGIN, make life easy to plugin devs :-) - define("THISPLUGIN", $hook[0]); + // 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]; @@ -329,6 +322,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