| 开发者 | amit |
|---|---|
| 更新时间 | 2026年8月22日 23:45 |
| PHP版本: | 8.4 及以上 |
| WordPress版本: | 7.1.0 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
update now link below the plugin listing on the plugins page in your wp-admin. That's quite easy!!
Do read the Important changes in 6.0.0 section above first. Your existing posts keep working, but there are a few things worth knowing before you open an old post in the block editor.
UPGRADING from v3.x
Just deactivate plugin in WordPress admin, delete the syntax_hilite.php file & ig_syntax_hilite directory from plugins folder and follow the installation process below. That's quite easy!!
UPGRADING from v2.1 or lower
Just deactivate plugin in WordPress admin, delete the syntax_hilite.php and geshi.php files & geshi directory from plugins folder and follow the installation process below. That's quite easy!!
Installing The Plugin
wp-admin area.Add New in the Plugins menu on left.iG:Syntax Hiliter in the search bar on the right on the page that opens and press Enter key.Activate Plugin link on the page that opens after the plugin has been installed successfully.If you are writing your post in the classic editor's Visual (WYSIWYG) tab then that is what is messing things up for you. That tab is TinyMCE, it treats your code as HTML and it does its damage before this plugin ever sees the content. It has never been supported. Use the block editor or the classic editor's Code view. If you are using either of those and still see this, please report it.
Because leaving them alone was worse. See the Important changes in 6.0.0 section above for the full explanation. Short version: the block editor loads a classic post into one big TinyMCE block, TinyMCE eats code and converting the snippets to blocks first is the only way to stop that. The conversion is only written to the post if you save it and it leaves the rest of your post byte-for-byte as it was.
Snippets still stored as shortcodes stay visible as [sourcecode]…[/sourcecode] text — ugly, but you can see them and do something about them. Snippets that have been converted to blocks render as nothing at all, because the block is no longer registered, and a Gist block goes the same way. Before deactivating, use the tool in the Before you deactivate section of the plugin's settings page to turn those blocks back into shortcodes — [sourcecode] for a code block and [github] for a Gist block. Every block converts, this plugin's own tags in the code included.
Both of those mechanisms are gone with GeSHi. Approx 300 languages ship with the plugin now, so start by checking whether yours is one of them — use it with [sourcecode language="…"] or pick it in the block.
Double its brackets. [[php]] shows a reader [php] and [[/php]] shows [/php], so a whole example fits inside a snippet:
[sourcecode language="php"]
[[sourcecode language="php"]]
echo 'hello';
[[/sourcecode]]
[/sourcecode]
Without this the snippet would end at the first closing tag in its code and everything after it would be lost. What is stored is what you typed — the extra brackets come off on the way to a reader and nowhere else — and the rule applies to itself, so [[[/php]]] shows a reader [[/php]].
By all means, feel free to submit a pull request.
Please feel free to suggest a new feature. Its inclusion might be speedier if you can provide the code to make it work.
<?php echo "<div>x</div>"; ?> as HTML. Posts never opened in the block editor are never converted, and editing in the classic editor's Code view converts nothing. Snippets are lifted out of the post before the block editor's parser reads it, so a post quoting block markup as an example is no longer taken apart on screen.[sourcecode language="…"] and a Gist block to [github gist="…"]. Either kind of block is invisible if the plugin is deactivated, so this is the way back out. It always writes the [sourcecode] form for code — semantically identical to the original [php]-style tag, but not a byte-for-byte round trip — and for a Gist it writes the address the block was already embedding. Every block converts: where the code holds one of this plugin's own tags, its brackets are doubled, which is how a snippet says a tag is text.[github] has always used, so the id handling, the link instead of a script in an excerpt and the Gist-in-comments setting all apply to it unchanged. Existing [github] shortcodes are not converted and go on working. The Before you deactivate tool converts the block back the other way, because a Gist block vanishes on deactivation just as a code block does.=>, !== and && as single glyphs, and the preview shows you what that looks like before you choose. None is the default, and it is the only choice that costs your visitors nothing: any other loads the font from Bunny Fonts, so each reader's browser makes one request to fonts.bunny.net. Bunny sets no cookies, keeps no logs and needs no account, but it is still a server that is not yours, so the plugin never calls it unless you ask it to. With None, code boxes keep the font your theme or your own CSS gives them, exactly as before. The chosen font is used in the block editor too, for the code inside the block as you type it, without the ligatures — in an editing box a merged glyph reads as though a character has gone missing.wptexturize, wpautop, autoembed, KSES and other plugins' filters now run over content containing no code at all, and what is stored is byte-for-byte what the author typed — including for users without the unfiltered_html capability.as, html, js, plus [sourcecode] and [github]. Any other tag is left completely alone so it cannot collide with another plugin's shortcode.geshi/ directory — in the plugin (v3.0) or in a theme (v4.1) — is no longer supported. The plugin has no geshi/ directory any more and does not look for one in a theme either. Such snippets will show up as ordinary post text with the [tag] markers visible. Approx 300 languages ship with the plugin now, so there is almost certainly one for what you were adding.file label sits above the code box, at the left, and is always visible whatever the toolbar setting says — in v5 it lived in the toolbar, so turning the toolbar off hid it too. A snippet given no file label gets no label element at all, but it still gets the wrapper — see the markup change below.highlight used together with firstline now refers to the line numbers as displayed, offset by firstline. GeSHi used the physical line numbers of the code.lang actually works now. In v5 both language and lang defaulted to code, so the alias was never reached and lang="php" was silently ignored.[php] and [css] did not render on many sites running v5.1, as several people reported. They work again.highlight attribute is capped at 10,000 lines in total — not per range. Once that many lines have been collected the rest of the attribute is ignored. v5 had no guard, so highlight="1-999999999" would build an enormous array.<pre> element carries the language class as well as the <code> inside it — every Prism theme selects on pre[class*="language-"].<div class="igsh-code-box">, which carries the box's id. Before, the wrapper appeared only when a file label was given and the id sat on the <pre>. Theme CSS selecting a code box as a direct child, such as .entry-content > pre, needs a descendant selector instead. Selectors on pre[class*="language-"] still work, and the <pre> keeps its classes and data- attributes.html, html4strict, html5 and xml become markup; mysql and postgresql become sql; oracle11 becomes plsql; jquery and js become javascript; rails becomes ruby; pcre becomes regex; actionscript3 and as become actionscript; java5 becomes java; apache becomes apacheconf; vb and vbnet become visual-basic; code and text become none, a styled but deliberately unhighlighted box. Three of these change the language rather than just its name: asp is now highlighted as ASP.NET (GeSHi's asp was classic ASP, which Prism has no component for), perl6 as Perl (Prism has no Raku component) and c_mac as plain C. The code itself is untouched in every case, only the colouring differs. A snippet converted to a block stores the mapped name rather than the tag, so that the block's language dropdown shows it.plaintext, toolbar and strict_mode attributes are accepted and ignored — GeSHi-era ideas with no Prism equivalent. Leaving them in an old post is harmless, they never reach the markup.[[php]] shows as [php], [[/php]] shows as [/php] — so a post about this plugin can put a whole [sourcecode]…[/sourcecode] example inside a code box. Until now a snippet ended at the first closing tag in its code and everything after it was lost. What is stored is what you typed, the extra brackets come off on the way to a reader and nowhere else, and the rule applies to itself, so [[[/php]]] shows a reader [[/php]]. This is not the same as WordPress's escape for a whole shortcode, which is the next entry and is unchanged.[[php]x[/php]] is stored with both pairs of brackets exactly as typed and stays that way across edits; on screen the outer pair comes off and you see [php]x[/php], the same thing WordPress does with any escaped shortcode. No code box is built for one, and an excerpt drops it along with the real snippets.[github gist="https://gist.github.com/…"] embeds the Gist it names. In v5 the embed ran at priority 10 on the_content, behind wptexturize, which curled the quotes around the URL before the plugin could read it — so every one of those embeds pointed at https://gist.github.com/.js and showed nothing. [github id="…"] escaped that only because it has no URL to mangle. The embed now runs at priority 9, ahead of wptexturize — and therefore ahead of anything else you have hooked to the_content at priority 10. Everything else about Gist embeds, including the option to allow them in comments, is unchanged.strip_shortcodes() now removes this plugin's tags as well, anywhere on the site, because the plugin hooks strip_shortcodes_tagnames. This is what stops an automatic excerpt printing a snippet as prose, but it is wider than excerpts — any caller of strip_shortcodes() is affected.__dir__ doesn't work below PHP 5.3 - props to Karol Kuczmarski for spotting it