void IWpPlugin.Configure(WpApp app) { if (app.Context.TryGetConstant("WPDOTNET_HOTPLUG_ENABLE", out var evalue) && (bool)evalue == false) { // docs/configuration/WPDOTNET_HOTPLUG_ENABLE // disable listing online plugins from dashboard app.OnAdminInit(() => { // plugins_api app.AddFilter("plugins_api", new Func <PhpValue, string, object, PhpValue>(EmptyApi), accepted_args: 3); app.AddFilter("themes_api", new Func <PhpValue, string, object, PhpValue>(EmptyApi), accepted_args: 3); }); return; } FirstRequest(); // delay the build action, // website is being just requested FoldersAction(f => f.PostponeBuild()); // wp hooks: app.OnAdminInit(() => { // render notices if there are compile time errors app.AdminNotices(() => CollectAdminNotices(app)); }); app.AdminMenu(() => { var hook = app.AddManagementPage("Code Problems", "Code Problems", "install_plugins", "list-problems", (output) => { var diagnostics = FoldersDiagnostic; var hasany = diagnostics.Any(); var maxseverity = hasany ? diagnostics.Max(d => d.Severity) : DiagnosticSeverity.Hidden; var overallicon = hasany ? IconHtml(maxseverity) : IconHtmlSuccess(); output.Write($@" <div style='margin:16px;'> <div><h1>Code Problems</h1></div> <div class='hide-if-no-js orange'> <div>{overallicon} {(maxseverity != 0 ? "Should be checked." : "No problems.")}</div> </div> </div>"); if (hasany) { output.Write("<div style='margin:24px;padding:8px;background:white;border:solid 1px #aaa;'>"); output.Write(CreateDiagnosticsTable(diagnostics, true)); output.Write("</div>"); } }, 4); //app.AddFilter($"load-{hook}", new Action(() => //{ // // //})); }); //// ajax hook to get the currently loaded assemblies version: //app.AddAjaxAction( // "hotplug_version", // () => (_pluginsCompiler.VersionLoaded.GetHashCode() ^ _themesCompiler.VersionLoaded.GetHashCode()).ToString("X")); //// TODO: add script to the footer that periodically checks ajax_hotplug_version for changes, //// in such case it refreshes the page // ... }
void IWpPlugin.Configure(WpApp app) { FirstRequest(); // delay the build action, // website is being just requested _pluginsCompiler.PostponeBuild(); _themesCompiler.PostponeBuild(); // wp hooks: app.OnAdminInit(() => { // render notices if there are compile time errors app.AdminNotices(() => CollectAdminNotices(app)); }); app.AdminMenu(() => { var hook = app.AddManagementPage("Code Problems", "Code Problems", "install_plugins", "list-problems", (output) => { var hasany = _pluginsCompiler.LastDiagnostics.Length != 0 || _themesCompiler.LastDiagnostics.Length != 0; var maxseverity = hasany ? _pluginsCompiler.LastDiagnostics.Concat(_themesCompiler.LastDiagnostics).Max(d => d.Severity) : DiagnosticSeverity.Hidden; var overallicon = hasany ? IconHtml(maxseverity) : IconHtmlSuccess(); output.Write($@" <div style='margin:16px;'> <div><h1>Code Problems</h1></div> <div class='hide-if-no-js orange'> <div>{overallicon} {(maxseverity != 0 ? "Should be checked." : "No problems.")}</div> </div> </div>"); if (_pluginsCompiler.LastDiagnostics.Length != 0 || _themesCompiler.LastDiagnostics.Length != 0) { output.Write("<div style='margin:24px;padding:8px;background:white;border:solid 1px #aaa;'>"); output.Write(CreateDiagnosticsTable(_pluginsCompiler.LastDiagnostics, true)); output.Write(CreateDiagnosticsTable(_themesCompiler.LastDiagnostics, true)); output.Write("</div>"); } }, 4); //app.AddFilter($"load-{hook}", new Action(() => //{ // // //})); }); app.Footer(output => { // output.Write(@$" // <div style='margin:4px auto;padding:6px;text-align:right;background:#eee;border-top:solid 1px #ccc;color:#444;font-size:13px;'> // Built with WordPress on .NET // </div>"); }); //// ajax hook to get the currently loaded assemblies version: //app.AddAjaxAction( // "hotplug_version", // () => (_pluginsCompiler.VersionLoaded.GetHashCode() ^ _themesCompiler.VersionLoaded.GetHashCode()).ToString("X")); //// TODO: add script to the footer that periodically checks ajax_hotplug_version for changes, //// in such case it refreshes the page // ... }