PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.26
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.26
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Libs / adminify-framework / fields / code_editor / code_editor.php

code_editor.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.26, at Libs/adminify-framework/fields/code_editor/code_editor.php

55 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: code_editor
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'ADMINIFY_Field_code_editor' ) ) {
11 class ADMINIFY_Field_code_editor extends ADMINIFY_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 $default_settings = array(
20 'tabSize' => 2,
21 'lineNumbers' => true,
22 'theme' => 'default',
23 'mode' => 'htmlmixed',
24 );
25
26 $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
27 $settings = wp_parse_args( $settings, $default_settings );
28
29 echo wp_kses_post( $this->field_before() );
30 echo '<textarea name="'. esc_attr( $this->field_name() ) .'"'. $this->field_attributes() .' data-editor="'. esc_attr( wp_json_encode( $settings ) ) .'">'. esc_textarea( $this->value ) .'</textarea>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- field_attributes() escapes each attribute via esc_attr()
31 echo wp_kses_post( $this->field_after() );
32
33 }
34
35 public function enqueue() {
36
37 $page = ( ! empty( $_GET[ 'page' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'page' ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change.
38
39 // Do not loads CodeMirror in revslider page.
40 if ( in_array( $page, array( 'revslider' ) ) ) { return; }
41
42 // Use WordPress core's bundled CodeMirror instead of shipping our own copy.
43 // wp_enqueue_code_editor() registers `code-editor` + `wp-codemirror` (with
44 // the common language modes) and exposes window.wp.CodeMirror.
45 if ( function_exists( 'wp_enqueue_code_editor' ) ) {
46 wp_enqueue_code_editor( array( 'type' => 'text/html' ) );
47 wp_enqueue_script( 'wp-codemirror' );
48 wp_enqueue_style( 'wp-codemirror' );
49 }
50
51 }
52
53 }
54 }
55