PluginProbe
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress / 3.2.5
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress v3.2.5
4.1.1 4.1.0 4.0.1 4.0.0 3.3.1 3.3.0 trunk 1.0.0 2.0.0 2.1.0 3.0.0 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8
quickwebp / admin / components / code-editor.php

code-editor.php in QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress 3.2.5, at admin/components/code-editor.php

35 lines 965 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Code editor component like theme editor for the settings page
4 */
5
6 $key_option = sanitize_key( $data['name'] );
7
8 if( isset( $key_option, $_POST[ $key_option ] ) ) {
9 update_option( $key_option, $_POST[ $key_option ] );
10 }
11 ?>
12 <textarea
13 name="<?php echo esc_attr( $key_option ?? '' ); ?>"
14 id="<?php echo esc_attr( $key_option ?? '' ); ?>"
15 ><?php echo esc_textarea( stripslashes( get_option( $key_option ?? '' ) ) ); ?></textarea>
16
17 <style>
18 <?php echo '.' . esc_attr( $key_option ) . '-container'; ?> > .CodeMirror {
19 height: <?php echo esc_attr( $data['height'] ?? "auto" ); ?>;
20 }
21 </style>
22
23 <?php
24 $settings = wp_enqueue_code_editor( array( 'type' => $data['mime_type'] ?? 'text/html' ) );
25
26 if ( $settings ) {
27 wp_add_inline_script(
28 'code-editor',
29 sprintf(
30 'jQuery( function() { wp.codeEditor.initialize( "'. $key_option .'", %s ); } );',
31 wp_json_encode( $settings )
32 )
33 );
34 }
35