Dieses Plugin ist nicht mit den jüngsten 3 Hauptversionen von WordPress getestet worden. Es wird möglicherweise nicht mehr gewartet oder unterstützt und kann Kompatibilitätsprobleme haben, wenn es mit neueren Versionen von WordPress verwendet wird.

Code Snippet

Beschreibung

Code Snippet was created by Roman Roan and originally hosted at http://blog.enargi.com. It is powered by the GeSHi engine and is quite possibly the best syntax highlighting engine for WordPress. A large number of languages are supported and it can be easily extended. Since his blog is no longer functioning, I’m attempting to keep his wonderful contribution available so I’ve given it a home at http://blog.hackerforhire.org/code-snippet/. If you find any bugs with it, let me know and I will do my best to resovle them.

Usage

The original author recommended always wrapping your code in a <pre> tag; however, most times you generally don’t need to. To use it, simply surround your code with as such and specify your language type:

[code lang=“c“]
int main(int argc, char** argv) { return 0; }
[/code]

And the result is:

int main(int argc, char** argv) { return 0; }

Supported Languages

This tool uses the GeSHi library. Any supported language there should work just fine with Code Snippet. See http://qbnz.com/highlighter/ for details.

Installation

  1. Copy archive to wp-content/plugins directory
  2. Extract the zip file
  3. When extracted properly you should have following directory structure: /wp-content/plugins/codesnippet
  4. Since I have not torn through the code, the plugin will probably not work if extracted/copied in diffrenet directory.
  5. Enable the plugin in the Plugin interface

FAQ

Do I need to wrap this my code in <code> block?

No. Instead, wrap your code in a <pre> block and then use [code lang=“lang“][/code] to wrap your code.

How can I customize the code block layout?

In the WordPress Admin interface, under Options -> Code Highlighting, you can specify a custom CSS stlye to wrap your code blocks in. While the preview button is nice, Firebug would be the tool I would recommend.

Can I use this with custom wordpress themes?

Yes; however, you might need to do a little bit of tweaking. JR found that CodeSnippet automatically adds a link if you’re theme is using wp_head; however, if it isn’t, you’ll need to add the link to the codesnippet/codesnippet.css stlye sheet to your header and you’ll also have to define the ‚codesnip-container‘ element. The default value is: border:1px solid #ccc; background:#eee; padding: 5px;margin:10px;

Rezensionen

8. Juli 2019
After upgrading my server to use PHP 7 as pestered to do so by WordPress, this plugin caused my site to break with a 500 error. PHP logs were able to show me that this plugin was the source of the error and after disabling it manually by SSHing into my box, my site was able to load again. There appear to be no updates for it and so WordPress refuses to reactivate it.
Lies alle 1 Rezension

Mitwirkende & Entwickler

„Code Snippet“ ist Open-Source-Software. Folgende Menschen haben an diesem Plugin mitgewirkt:

Übersetze „Code Snippet“ in deine Sprache.

Interessiert an der Entwicklung?

Durchstöbere den Code, sieh dir das SVN Repository an oder abonniere das Entwicklungsprotokoll per RSS.

Änderungsprotokoll

2.1.7

  • Updating verison mis-match again
  • Updating to GeSHi 1.0.8.6

2.1.6

  • Updating readme. Validated testing with 2.9.2

2.1.5

  • Updating tag in plugin causing incorrect version to display

2.1.4

  • GeSHi engine 1.0.8.4, rendering bug-fix

2.1.2

  • Update to work with plugin security in 2.8.1

2.0

  • Tested with WordPress 2.0

1.5

  • various improvements

1.4

  • Fixed: Plugin Options panel is not displayed (Options>Code Highlighting)

1.3

  • Fixed: RSS feeds got broken with code snippets

1.2

  • Fixed: invalid css stylesheet link when WordPress is not installed in site root

1.1

  • Fixed plugin produce errors under PHP 4

1.0

  • Initial release