Linux 软件免费装
Banner图

Preserve Code Formatting

开发者 coffee2code
更新时间 2021年4月14日 15:50
捐献地址: 去捐款
PHP版本: 4.9 及以上
WordPress版本: 5.7
版权: GPLv2 or later
版权网址: 版权信息

标签

content writing code formatting display coffee2code escape post body

下载

2.0 2.5 2.5.1 2.5.2 2.5.3 2.5.4 3.0 3.1 3.2 3.5 3.6 3.7 3.8 3.9 3.9.1 3.9.2 4.0 4.0.1

详情介绍:

This plugin preserves formatting of code for display by preventing its modification by WordPress and other plugins while also retaining whitespace. 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: Keep these things in mind: Example: 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

安装:

  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 block 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.

屏幕截图:

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

升级注意事项:

4.0.1 Recommended bugfix release: fixed a bug preventing settings from getting saved; updated plugin framework to v061 4.0 Recommended update: prevented potential conflicts with other plugins (such as SyntaxHighlighter), updated the plugin framework, noted compatibility through WP 5.7+, and updated copyright date (2021). 3.9.2 Minor update: updated plugin framework, added a TODO.md file, updated a few URLs to be HTTPS, expanded unit testing, updated compatibility to be WP 4.9 through 5.4+, and minor documentation tweaks. 3.9.1 Bugfix update: fixed bug to prevent handling of posts containing a code block, noted compatibility through WP 5.3+, and updated copyright date (2020) 3.9 Minor update: tweaked plugin initialization, updates plugin framework to version 049, noted compatibility through WP 5.1+, created CHANGELOG.md to store historical changelog outside of readme.txt, and updated copyright date (2019) 3.8 Recommended minor update: updates plugin framework to version 046; compatibility is now with WP 4.7-4.9+; updated copyright date (2018). 3.7 Minor update: improve support for localization; verified compatibility through WP 4.5; removed compatibility with WP earlier than 4.1; updated copyright date (2016) 3.6 Minor update: added more unit tests; updated plugin framework to 039; noted compatibility through WP 4.1+; updated copyright date (2015); added plugin icon 3.5 Recommended update: fix bug where 'pre' tag could get wrapped in ' ' tag; added setting to disable preserving code in posts; added unit tests; updated plugin framework; compatibility now WP 3.6-3.8+ 3.3 Minor update. Highlights: added setting to control if code should be preserved in posts; prevent 'pre' tag from getting wrapped in 'pre'; updated plugin framework. 3.2 Recommended update. Highlights: fixed bug with settings not appearing in MS; updated plugin framework; noted compatibility with WP 3.3+; dropped compatibility with versions of WP older than 3.1. 3.1 Recommended update. Highlights: fixed numerous bugs; added a debug mode; updated compatibility through WP 3.2; dropped compatibility with version of WP older than 3.0; updated plugin framework; and more. 3.0.1 Trivial update: updated plugin framework to v021; noted compatibility with WP 3.1+ and updated copyright date. 3.0 Recommended update. Highlights: re-implementation using custom plugin framework; full localization support; misc non-functionality documentation and formatting tweaks; renamed class; verified WP 3.0 compatibility; dropped support for versions of WP older than 2.8.

常见问题:

Why does my code still display all funky (for instance, I'm seeing & in places where I expect to see &)?

Are you using the visual editor? The visual editor has a tendency to screw up some of your intent, especially when you are attempting to include raw code. This plugin does not make any claims about working when you create posts with the visual editor enabled. How to tell if you're using the visual editor: you're using what is now referred to as the Classic Editor (the editing experience in WordPress that pre-dates the block editor since WordPress 5.0). Above the post content field and to the right, there is a tab labeled "Visual" and another labeled "Text". If you're writing code, you want to use "Text" for such posts and not switch back to "Visual".

Can I put shortcode examples within code tags and not have them be evaluated by WordPress?

Yes, shortcodes within code tags (or any tag processed by this plugin) will be output as pure text and not be processed as shortcodes by WordPress.

Is this plugin compatible with the code block in the block editor?

Yes, in the sense that it doesn't do anything at all. The code block in the block editor should preserve code formatting without this plugin's intervention. (If you have older content that predates the block editor and has not been converted to blocks, you'll still want to keep this plugin active to preserve code formatting in those older posts. But having this plugin active won't interfere with the behavior of code blocks.)

Does this plugin include unit tests?

Yes.

更新日志:

4.0.1 (2021-04-14) 4.0 (2021-04-03) Highlights: Details: 3.9.2 (2020-07-01) Highlights: Details: Full changelog is available in CHANGELOG.md.