🔥 Black Friday Sale: Get 65% OFF Any PageForge Pro Plan! Use code BF65 Claim Offer →
Compte Get it free
Preserve Code Formatting icon
Ralentir Testé jusqu'à 6.8.13 #29 in code

Preserve Code Formatting

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

Installations actives400+100+ niveaux
Téléchargements · 30D256▲ +12.3% vs prev. 30d
Évaluation4.7/53 avis
Score de santé42/100Juste
Téléchargements de tous les temps50.3KSince Apr 2005
Support résolu—Aucun fil de discussion récent
A besoin deWP 5.5Php tout
Téléchargements · 7j62• 0% semaine après semaine
Notre verdict

Utiliser avec prudence

Preserve Code Formatting works, but test it on a staging site before relying on it in 2026. It runs on 400+ sites, is rated 4.7/5 and was last updated 1 year ago, and scores 42/100 on our health check.

  • Petite base d'utilisateurs (400+ installations actives)
  • Très peu de critiques jusqu'à présent
  • Pas de mise à jour depuis plus d'un an
  • Uniquement testé jusqu'à WordPress 6,8 (le dernier est de 7,1)

Comment s'accumule-t-il ?

Côte à côte sur les installations, les mises à jour, les évaluations et le support

Téléchargements quotidiens

4812Aug 31Oct 14Nov 28
Hier7
Moyenne quotidienne (1 ans)5
Jour de pointe16Nov 24, 2026
12 Derniers mois1.8K

Les pics de téléchargement suivent généralement une nouvelle version - chaque site qui met à jour automatiquement compte comme un téléchargement.

Classements

Where Preserve Code Formatting stands today

WordPress.org Classements de recherche

Position en direct dans la recherche de plugins, Top 100
Mot-cléPositionPlugins concurrentsCatégorie
code >100 10,000 Meilleurs plugins de code →
content >100 10,000 Best content plugins →
escape #24 2,525 Best escape plugins →
mise en forme #3 3,401 Meilleurs plugins de formatage →
poster >100 10,000 Meilleurs plugins de publication →

Adoption de version

Part de sites actifs par version.

  • 5.065.8%
  • 4.019.3%
  • 3.78.0%
  • 3.96.9%

Répartition des notes

★★★★★★★★★★ 4.7 from 3 reviews

  • 5★66.7%
  • 4★33.3%
  • 3★0.00%
  • 2★0.00%
  • 1★0.00%

About Preserve Code Formatting

From the official readme · v5.0

Description

This plugin preserves formatting of code for display by preventing its modification by WordPress and other plugins while also retaining whitespace.

NOTE: This plugin does NOT handle posts containing blocks. For such posts, use the built-in code or preformatted blocks to format your code for display. However, this plugin would still be needed if you have text-based posts from before using the blocks-based editor.

NOTE: Use of the visual text editor will pose problems as it can mangle your intent in terms of code tags. I strongly suggest you not use the visual editor in conjunction with this plugin as I have taken no effort to make the two compatible.

Notes:

Basically, you can just paste code into code, pre, and/or other tags you additionally specify and this plugin will:

  • Prevent WordPress from HTML-encoding text (i.e. single- and double-quotes will not become curly; “–” and “—” will not become en dash and em dash, respectively; “…” will not become a horizontal ellipsis, etc)
  • Prevent most other plugins from modifying preserved code
  • Prevent shortcodes from being processed
  • Optionally preserve whitespace (in a variety of methods)
  • Optionally preserve code added in comments

Keep these things in mind:

  • ALL embedded HTML tags and HTML entities will be rendered as text to browsers, appearing exactly as you wrote them (including any br tags).
  • By default this plugin filters ‘the_content’ (post content), ‘the_excerpt’ (post excerpt), and ‘get_comment_text (comment content)’.

Exemple :

A post containing this within code tags:

$wpdb->query("
        INSERT INTO $tablepostmeta
        (post_id,meta_key,meta_value)
        VALUES ('$post_id','link','$extended')
");

Would, with this plugin enabled, look in a browser pretty much how it does above, instead of like:

$wpdb->query(—
INSERT INTO $tablepostmeta
(post_id,meta_key,meta_value)
VALUES ('$post_id','link','$extended')
―);

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage

Installation

  1. Whether installing or updating, whether this plugin or any other, it is always advisable to back-up your data before starting
  2. Install via the built-in WordPress plugin installer. Or download and unzip preserve-code-formatting.zip inside the plugins directory for your site (typically wp-content/plugins/)
  3. Activate the plugin through the ‘Plugins’ admin menu in WordPress
  4. Go to the Settings -> Code Formatting admin settings page (which you can also get to via the Settings link next to the plugin on the Manage Plugins page) and customize the settings.
  5. Write a post with code contained within opening and closing code tags. If you are using the block editor (aka Gutenberg), then this plugin is only useful for maintaining code formatting for posts written before WP 5.0 (or whenever you started creating posts with the block editor). You should be using the built-in code or preformatted blocks when including code into the block editor. Otherwise, if you are actively using the classic editor, be sure to use the HTML (aka “Text”) editor and not the “Visual” editor or you’ll encounter formatting issues.

Journal de modifications

Major release: significant improved security, performance, compatibility. Updated plugin framework to v070 for enhanced security, features. Excluded all block editor content (plugin only designed for text view). Added class to preserved tags. WP compat now 5.5-6.8+. Updated copyright date (2025).

5.0 (2025-08-10)

Highlights:

This major release significantly improves security, performance, and compatibility. The plugin framework updates to version 070 for enhanced security and features. Block editor content is now properly excluded (the plugin was designed for text view), and compatibility extends through WordPress 6.8+ while dropping support for versions older than 5.5. Additional improvements include better error handling, enhanced documentation, and the addition of CSS classes for styling processed code blocks.

Details:

  • Security and hardening:
    • Hardening: Prevent regex pattern injection vulnerability
    • Hardening: Prevent object injection vulnerability. Props Patchstack.
    • Hardening: Prevent bypassing preprocessor by removing any explicit pseudo-tags from content
    • Hardening: Prevent processing of excessively large content
    • Hardening: Prevent unintended markup in translated strings before display
    • Hardening: Prevent content-native usage of token string used internally to chunk data
  • Performance:
    • Change: Improve performance of processing tags to be preserved
    • Change: Bail early if there are no tags configured to be preserved
    • Change: Skip tags that have no content
    • Change: Centralize regex patterns in new get_preprocess_regex_pattern() and get_postprocess_regex_pattern()
    • Change: Use more efficient preg_replace_callback() for tag extractions
  • Block editor and content handling:
    • New: Prevent processing of all block editor content (plugin was designed for text view, not block editor)
    • Fix: Prevent unintended greediness when multiple instances of a tag are present
  • UI and styling:
    • New: Output class of “preserve-code-formatting” for all tags that were processed
    • Change: Output example ‘code’ and ‘pre’ tags within ‘code’ tags within setting page description
  • Framework and compatibility:
    • Change: Update plugin framework to 070
    • Change: Note compatibility through WP 6.8+
    • Change: Drop compatibility with versions of WP older than 5.5
    • Change: Note compatibility through PHP 8.3+
    • Change: Update copyright date (2025)
  • Code quality and documentation:
    • New: Add FAQ entry explaining nested tag deficiency
    • Change: Update get_c2c_string() to add new strings
    • Change: Improve some docblock documentation
    • Change: Tweak some README.md formatting
    • Change: Tweak installation instructions
    • Change: Reduce number of tags defined in readme.txt
    • Change: Note removal of development and testing related files from release packaging
    • Change: Add missing release dates for earlier releases, as well as add an omitted release

4.0.1 (2021-04-14)

  • Fix: Update plugin framework to 061 to fix a bug preventing settings from getting saved

4.0 (2021-04-03)

Highlights:

  • This recommended release prevents potential conflicts with other plugins (such as SyntaxHighlighter), updates the plugin framework, and notes compatibility through WP 5.7+.

Details:

  • Change: Use {!{ and }!} instead of [[ and ]] to prevent interpretation as shortcodes, fixing conflict with SyntaxHighlighter. Props azito122.
  • Change: Update plugin framework to 060
    • 060:
    • Rename class from c2c_{PluginName}_Plugin_051 to c2c_Plugin_060
    • Move string translation handling into inheriting class making the plugin framework code plugin-agnostic
      • Add abstract function get_c2c_string() as a getter for translated strings
      • Replace all existing string usage with calls to get_c2c_string()
    • Handle WordPress’s deprecation of the use of the term “whitelist”
      • Change: Rename whitelist_options() to allowed_options()
      • Change: Use add_allowed_options() instead of deprecated add_option_whitelist() for WP 5.5+
      • Change: Hook allowed_options filter instead of deprecated whitelist_options for WP 5.5+
    • New: Add initial unit tests (currently just covering is_wp_version_cmp() and get_c2c_string())
    • Add is_wp_version_cmp() as a utility to compare current WP version against a given WP version
    • Refactor contextual_help() to be easier to read, and correct function docblocks
    • Don’t translate urlencoded donation email body text
    • Add inline comments for translators to clarify purpose of placeholders
    • Change PHP package name (make it singular)
    • Tweak inline function description
    • Note compatibility through WP 5.7+
    • Update copyright date (2021)
    • 051:
    • Allow setting integer input value to include commas
    • Use number_format_i18n() to format integer value within input field
    • Update link to coffee2code.com to be HTTPS
    • Update readme_url() to refer to plugin’s readme.txt on plugins.svn.wordpress.org
    • Remove defunct line of code
  • Change: Move translation of all parent class strings into main plugin file
  • Change: Note compatibility through WP 5.7+
  • Change: Update copyright date (2021)

Full changelog is available in CHANGELOG.md.

Journal des modifications complet sur WordPress.org →

Captures d'écran

A screenshot of the plugin's admin options page.
A screenshot of the plugin's admin options page.

Pour les développeurs

Est-ce votre plugin ? Montrez les chiffres.

Ajoutez un badge en direct à votre site, docs ou github readme. Il se met à jour par lui-même - aucun compte n'est nécessaire.

Badge d'installations actives Badge Badge de score de santé

Best Preserve Code Formatting alternatives

Tous les plugins de code →
Alternatives
Rang Plugin Installations actives Évaluation Mise à jour Santé
1 WPCode – Insérer des en-têtes et des pieds de page + extraits de code personnalisés – WordPress Gestionnaire de code Wpcode Ajoutez facilement des extraits de code dans WordPress. Insérez des scripts d'en-tête et de pied de page, ajoutez du code PHP… de Syed Balkhi 3M+ ★★★★★★★★★★ 4.9 (1.9K) Il y a 2 semaines 94
2 Extraits de code Extraits de code Gérez le code WordPress personnalisé dans un seul tableau de bord. Créez des extraits de PHP et HTML, prévisualisez le code… par codes d'extraits de pro 1M+ ★★★★★★★★★★ 4.7 (510) il y a 4 jours 93
3 Code de la tête et du pied de page Code de la tête et du pied de page Ajoutez un code personnalisé à l'échelle du site, de la catégorie et de l'article avant la clôture et… Par Aleksandar Urošević 100K+ ★★★★★★★★★★ 5 (51) Il y a 3 mois 77
4 Plugin CSS personnalisé simple Plugin CSS personnalisé simple Ajoutez un CSS personnalisé à votre site WordPress sans aucun problème. de John Regan 100K+ ★★★★★★★★★★ 4.7 (159) Il y a 2 ans 51
5 Shortcoder — Créez des shortcodes pour tout Shortcoder — Créez des shortcodes pour tout Créez facilement des "shortcodes" personnalisés pour les extraits de code HTML, JavaScript, CSS et utilisez les… par vaakash 100K+ ★★★★★★★★★★ 4.9 (227) Il y a 3 mois 77
6 Scripts n Styles Scripts n Styles Ce plugin permet aux utilisateurs administrateurs d'ajouter individuellement du HTML, du CSS personnalisé, des classes et de JavaScript… Par soft 30K+ ★★★★★★★★★★ 4.4 (30) Il y a 3 ans 45
7 SyntaxeHighlighter évolué SyntaxeHighlighter évolué Publiez facilement le code mis en évidence par la syntaxe sur votre site sans avoir à modifier le code du tout… par Alex Mills 20K+ ★★★★★★★★★★ 4.3 (86) il y a 5 jours 73
8 Code d'intégration Code d'intégration Code Embed offre un moyen très simple et efficace d'intégrer du code (JavaScript, CSS et HTML)… par David Artiss 10K+ ★★★★★★★★★★ 4.4 (45) il y a 6 jours 87
9 Advance HTML personnalisé - Affichez le code en direct, partagez des extraits, intégrez du code et stylisez-les à votre façon. Avancer le code HTML personnalisé Advance HTML personnalisé vous permet d'écrire et d'afficher des extraits de code HTML, CSS, PHP et autres… par BPlugins 10K+ ★★★★★★★★★★ 2.5 (4) Il y a 2 semaines 68
10 Mise en évidence du bloc de code Mise en évidence du bloc de code Ajoutez un bloc de code avec la mise en évidence de la syntaxe à l'aide de Prism.js. (Disponible pour Gutenberg et… par Loos 10K+ ★★★★★★★★★★ 4.5 (20) il y a 5 mois 62

FAQ

Preserve Code Formatting: quick answers

Réponses directes, extraites des données en direct WordPress.org.

Source : WordPress.org

Is Preserve Code Formatting free?

Yes. Preserve Code Formatting is free to download and use from the official WordPress.org plugin directory.

Is Preserve Code Formatting safe to use in 2026?

Preserve Code Formatting works, but test it on a staging site before relying on it in 2026. It runs on 400+ sites, is rated 4.7/5 and was last updated 1 year ago, and scores 42/100 on our health check.

How many websites use Preserve Code Formatting?

Preserve Code Formatting is active on 400+ WordPress websites and has been downloaded 50,349 times since it launched in April 2005. It was downloaded 256 times in the last 30 days.

Does Preserve Code Formatting work with WordPress 7.1?

Preserve Code Formatting is officially tested up to WordPress 6.8.13, while the latest release is 7.1.5. It may still work, but try it on a staging site first.

When was Preserve Code Formatting last updated?

The latest version, 5.0, was released on August 15, 2025 (1 year ago).

Who makes Preserve Code Formatting?

Preserve Code Formatting is developed and maintained by Scott Reilly.

What are the best alternatives to Preserve Code Formatting?

The most popular alternatives to Preserve Code Formatting are WPCode (3M+ installs), Code Snippets (1M+ installs) and Head & Footer Code (100K+ installs).

Propulsé par PageForge

Un modèle et une feuille de calcul. Une vraie page pour chaque recherche.

PageForge transforme chaque ligne d'un CSV en une page WordPress avec son propre titre, URL, SEO et schéma, construit sur la mise en page que vous Déjà conçu. Gratuit sur WordPress.org.

  • CSV et XLSX, plus Google Sheets sur les professionnels et les entreprises
  • Son propre titre, URL, SEO champs et schéma pour chaque page
  • Fonctionne avec l'éditeur de blocs, Elementor, Divi et Avada
  • Gratuit sur WordPress.org, pas de carte de crédit

↑↓ bouger↵ ouvrir