PluginProbe
Code Snippets / trunk
Code Snippets vtrunk
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
← All changes | php/Utils/editor.php +38 -2 4.0.0-beta.1 → trunk View file →
@@ -43,9 +43,9 @@
43 43 'Alt-Up' => 'swapLineUp',
44 44 'Alt-Down' => 'swapLineDown',
45 45 ],
46 46 'gutters' => [ 'CodeMirror-lint-markers', 'CodeMirror-foldgutter' ],
47 - 'lint' => 'css' === $type || 'php' === $type,
47 + 'lint' => 'php' === $type,
48 48 'direction' => 'ltr',
49 49 'colorpicker' => [ 'mode' => 'edit' ],
50 50 'foldOptions' => [ 'widget' => '...' ],
51 51 ];
@@ -93,9 +93,45 @@
93 93 PLUGIN_VERSION,
94 94 [ 'in_footer' => true ]
95 95 );
96 96
97 - // CodeMirror Theme.
97 + enqueue_code_editor_theme();
98 +}
99 +
100 +/**
101 + * Load the CodeMirror assets required for read-only code previews.
102 + *
103 + * @param string $type Type of code editor – either 'php', 'css', 'js', or 'html'.
104 + *
105 + * @return void
106 + */
107 +function enqueue_code_preview_editor( string $type ): void {
108 + $modes = [
109 + 'css' => 'text/css',
110 + 'php' => 'text/x-php',
111 + 'js' => 'javascript',
112 + 'html' => 'application/x-httpd-php',
113 + ];
114 +
115 + wp_enqueue_code_editor(
116 + [
117 + 'type' => $modes[ $type ] ?? $modes['php'],
118 + 'codemirror' => [
119 + 'lint' => false,
120 + 'readOnly' => true,
121 + ],
122 + ]
123 + );
124 +
125 + enqueue_code_editor_theme();
126 +}
127 +
128 +/**
129 + * Load the configured CodeMirror theme.
130 + *
131 + * @return void
132 + */
133 +function enqueue_code_editor_theme(): void {
98 134 $theme = get_setting( 'editor', 'theme' );
99 135
100 136 if ( 'default' !== $theme ) {
101 137 wp_enqueue_style(