From b98a1777754327abfd27f2869609e0af4e2100c8 Mon Sep 17 00:00:00 2001 From: DeltaLima Date: Wed, 21 Jun 2023 00:21:46 +0200 Subject: [PATCH] cleanup, wip save --- plugin.syntaxhighlighter.php | 92 ++++++++++-------------------------- 1 file changed, 24 insertions(+), 68 deletions(-) diff --git a/plugin.syntaxhighlighter.php b/plugin.syntaxhighlighter.php index 50ff1fb..25330eb 100644 --- a/plugin.syntaxhighlighter.php +++ b/plugin.syntaxhighlighter.php @@ -1,11 +1,11 @@ dp.SyntaxHighlighter 1.4.0 (edited to work with pre, thanks to Gert Thiel ) -Author: NoWhereMan -Author URI: http://flatpress.sf.net +Plugin URI: https://git.la10cy.net/DeltaLima/flatpress-plugin-syntaxhighlighter-ng +Description: SyntaxHighlighter-NG 1.0.0 (forked from Arvid's forum post, using now prism.js) +Author: 2005 NoWhereMan, 2023 DeltaLima +Author URI: https://deltalima.org */ @@ -13,52 +13,12 @@ function plugin_syntaxhighlighter_add($lang=null) { static $languages = array(); $pdir=plugin_geturl('syntaxhighlighter'); - - //if ($lang) { - //~ switch ($lang) { - //~ case 'c': - //~ case 'cpp': - //~ case 'c++': - //~ $scripts[] = "\n"; break; - //~ case 'css': - //~ $scripts[] = "\n"; break; - //~ case 'c#': - //~ case 'c-sharp': - //~ case 'csharp': - //~ $scripts[] = "\n"; break; - //~ case 'vb': - //~ case 'vb.net': - //~ $scripts[] = "\n"; break; - //~ case 'delphi': - //~ case 'pascal': - //~ $scripts[] = "\n"; break; - //~ case 'js': - //~ case 'jscript': - //~ case 'javascript': - //~ $scripts[] = "\n"; break; - //~ case 'php': - //~ $scripts[] = "\n"; break; - //~ case 'py': - //~ case 'python': - //~ $scripts[] = "\n"; break; - //~ case 'ruby': - //~ $scripts[] = "\n"; break; - //~ case 'sql': - //~ $scripts[] = "\n"; break; - //~ case 'xml': - //~ case 'xhtml': - //~ case 'xslt': - //~ case 'html': - //~ case 'xhtml': - //~ "\n"; - - //~ } + // create array containing the used languages $languages[] = "{$lang}"; + // remove unique $languages = array_unique($languages); - //} - //return $scripts; return $languages; } @@ -66,14 +26,13 @@ function plugin_syntaxhighlighter_add($lang=null) { function plugin_syntaxhighlighter_head() { $pdir=plugin_geturl('syntaxhighlighter'); -echo << +echo << - - -SHL; + +PRISMJS; } add_action('wp_head', 'plugin_syntaxhighlighter_head'); @@ -81,25 +40,22 @@ add_action('wp_head', 'plugin_syntaxhighlighter_head'); function plugin_syntaxhighlighter_foot() { - //$used_languages = implode(plugin_syntaxhighlighter_add(), "\n"); + // convert the returned array into an json one, to have an easier time + // giving it to the javascript below $used_languages = json_encode(plugin_syntaxhighlighter_add()); - $pdir=plugin_geturl('syntaxhighlighter'); - echo << - - - - - + $pdir=plugin_geturl('syntaxhighlighter'); + // javascript part + echo << + + -SHLBOX; +PRISMBOX; } add_action('wp_footer', 'plugin_syntaxhighlighter_foot');