void SwitchTheme(string new_name, WP_Theme new_theme, WP_Theme old_theme = null) { Debug.WriteLine($"Switching theme from {old_theme.get_stylesheet()} to {new_theme.get_stylesheet()} ..."); _packages.DeactivatePackage(old_theme.get_stylesheet().ToString()); _packages.ActivatePackage(new_theme.get_stylesheet().ToString()); }
void AdminInit(WpApp app) { // plugins_api app.AddFilter("plugins_api", new Func <PhpValue, string, object, PhpValue>(PluginsApi), accepted_args: 3); app.AddFilter("delete_plugin", new Action <string>(DeletePlugin)); app.AddFilter("upgrader_source_selection", new Func <string, PhpValue>(InstallSourceSelection), priority: 0); app.AddFilter("activate_plugin", new Action <string>(plugin_file => _packages.ActivatePackage(PackagesHelper.PluginFileToPluginId(plugin_file)))); app.AddFilter("deactivate_plugin", new Action <string>(plugin_file => _packages.DeactivatePackage(PackagesHelper.PluginFileToPluginId(plugin_file)))); app.AddFilter("install_plugins_tabs", new Func <PhpArray, PhpArray>(tabs => // remove unsupported tabs { //tabs.Remove(new IntStringKey("upload")); tabs.Remove(new IntStringKey("popular")); tabs.Remove(new IntStringKey("recommended")); tabs.Remove(new IntStringKey("favorites")); tabs["recommended"] = "Premium"; return(tabs); })); app.Context.DefineConstant("FS_METHOD", "direct"); // overwrite how installing plugins is handled, skips the fs check }