Thursday, 31 January 2019

How to Add The CodeMirror Editor to any WordPress Plugin or Theme


CodeMirror is a versatile JavaScript component that turns any HTML textarea into a full-featured code editor with out-of-the-box support for over 120 (programming) languages. It’s neither the first nor the only such component, but it’s the one that was added to the WordPress core in v4.9 to improve the code editing experience; specifically, syntax highlighting, linting, and code competition. Live code editing is frowned upon by many, but it’s also used by even more users who need to do just a bit of tweaking on their site. That tweaking (and CodeMirror) is available in Appearance – Editor where you can edit theme files, in Plugins – Editor where you do the same with plugins, and in Customizer – Additional CSS. Since CodeMirror is available in the core and super-easy to add to any plugin or theme, we’ll have a look at how you can make your plugin better and more user-friendly with just a few lines of code.
Do I need this CodeMirror thing?
If your plugin has any input fields where users enter code snippets, then you most surely need CodeMirror. Even if it’s just a few lines of custom CSS, the improvement in user experience that you’ll
Source: https://managewp.org/articles/18347/how-to-add-the-codemirror-editor-to-any-wordpress-plugin-or-theme



source https://williechiu40.wordpress.com/2019/01/31/how-to-add-the-codemirror-editor-to-any-wordpress-plugin-or-theme/

No comments:

Post a Comment