Package/plugin/module WordPress

Preserve Code Formatting v2.5

I’d like to announce the official release of the updated Preserve Code Formatting plugin (v2.5) for WordPress.

Preserve formatting of code for display by preventing its modification by WordPress and other plugins while retaining original whitespace and characters.

The plugin’s official homepage is located at :

This release features a fix for a long-running (and frustrating) bug where preserved code would occasionally appear garbled. This release also feature many behind-the-scenes plugin management code updates. The plugin extends support through WordPress v2.8+, but drops support for versions of WordPress older than v2.6.

Comments welcome on this post for this version of the plugin. Comments will be closed once this release has been superseded by another.

Update: Plugin updated to v2.5.1

Update 2: Plugin updated to v2.5.2

Update 3: Plugin updated to v2.5.3

Update 4: Plugin updated to v2.5.4

Read comments for details of the various updates.

Read more for a detailed ChangeLog of the release.

Detailed ChangeLog

These are the detailed changes, which may or may not make sense to you depending on your familiarity with the previous features and internals of the plugin.

  • Fixed long-running bug that caused some preserved code to appear garbled
  • Updated a lot of internal plugin management code
  • Added ‘Settings’ link to plugin’s plugin listing entry
  • Used plugins_url() instead of hardcoded path
  • Brought admin markup in line with modern conventions
  • Minor reformatting (spacing)
  • Noted compatibility through WP2.8+
  • Dropped support for pre-WP2.6
  • Updated copyright date
  • Updated screenshot
  • Updated to v2.5

23 replies on “Preserve Code Formatting v2.5”

Plugin has been updated to v2.5.1

I’ve released a new update to the plugin that does the following:

* Fixed newly introduced bug that added unnecessary slashes to preserved code
* Fixed long-running bug where intended slashes in code got stripped on display (last remaining known bug)

Hi Scott.

I seem to be getting the following errors throughout my blog (both in published posts and in the dashboard/admin area):

Warning: gzuncompress() [function.gzuncompress]: data error in /home/david/public_html/ on line 371

It’s occurring in the preserve_postprocess function.

Any idea (before I investigate further) as to what’s causing this?


ps. Thanks for a very handy product! 🙂


I encountered the same issue as well (though with less frequency). I managed to resolve it using code updates I’ve made available here. Mind testing that update to see if it eliminates those errors (and without introducing any new ones) and reporting back? Thanks!

Hi Scott,

The problem goes away with the code you pointed me to (2.5.2-beta).

I see you’ve changed from using gzuncompress to gzinflate. Function behaviour had changed, I gather?

Thanks very much.



Thanks for reporting back, David. I changed from using gzcompress/gzuncompress to gzdeflate/gzinflate. The gzuncompress error was vague and the docs seem to suggest the possibility of it having problems with certain sized data. The alternate implementation I went with seems to be better.

This plugin has been updated to v2.5.2

I’ve released a new update to the plugin that does the following:

* Fixed newly introduced bug that occasionally generated a gzuncompress() error (and prevented related code from displaying)
* Fix to retain attributes that had been provided for preserved tags

Hi Scott

I’ve upgraded to 2.5.2, and I’m currently experiencing the following error, now in gzinflate:

Warning: gzinflate() [function.gzinflate]: data error in /data01/isr/public_html/wp-content/plugins/preserve-code-formatting/preserve-code-formatting.php on line 372

I only experience this on a couple of posts – but the same posts each time.

Anything I can send you to help diagnose the problem further?



Do you mind e-mailing me the entire contents of one of the posts that consistently generates the error? Thanks.


the v2.5.3-beta fixes the error for me and does not seem to cause other problems. I don’t make heavy use of your plugin, so there is no guarantee, but for me everything is fine 🙂 !

Thank you for your work! Great 🙂


The tentative 2.5.3 version worked for me as well. I’d upgraded the plugin to 2.5.2 from a much earlier version that was incompatible with the current WP version, 2.8.4. It threw the error described by others here. Any idea what’s going on?

Jan: Thanks for reporting back!

AlanK: Ah, thanks for finding the settings page bug. You can still get to the setting page under the admin “Settings” listing of settings pages, but in v2.5.3 that I’m about to release, the “Settings” link in the plugin’s listing will be fixed. You seem to be confirming that 2.5.3-beta is otherwise good for you?

Yes, since installing the beta version of your impending release, there has been no further incident. Thanks very much for attending to the issue. Most appreciated.

This plugin has been updated to v2.5.3

I’ve released a new update to the plugin that does the following:

* Fixed recently introduced bug affecting occasional code preservation by using a more robust alternative approach
* Fixed “Settings” link for plugin in plugin listing, which lead to blank settings page
* Changed help text for preservable tags settings input to be more explicit

Hi Scott,

First of all thanks for this plugin.

However, v2.5.3 does funny things to my post that 2.5.2 doesn’t.

I’ve left the blog on 2.5.3 so that you can check it out. The bit that doesn’t look right should read:

“#include “level1/level2/level3/level4/filename.h”

Please let me know if you can see the problem. If you want me to send you the complete blog source that’s not a problem.


John: Yup, you’re right. Seems like I backed out some thing in the 2.5.3 release that needed to remain. A new release will be soon forthcoming. Thanks for the report!

This plugin has been updated to v2.5.4

I’ve released a new update to the plugin that does the following:

* Fixed some borked code preservation by restoring some processing removed in previous release

Comments are closed.