PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.3.3
StreamCast – bring live radio to your site with a sleek player v2.3.3
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / admin / codestar-framework / fields / code_editor / code_editor.php

code_editor.php in StreamCast – bring live radio to your site with a sleek player 2.3.3, at admin/codestar-framework/fields/code_editor/code_editor.php

59 lines 2.1 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( 'CSF_Field_code_editor' ) ) {
11 class CSF_Field_code_editor extends CSF_Fields {
12
13 public $version = '6.65.7';
14 public $cdn_url = 'https://cdn.jsdelivr.net/npm/codemirror@';
15
16 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
17 parent::__construct( $field, $value, $unique, $where, $parent );
18 }
19
20 public function render() {
21
22 $default_settings = array(
23 'tabSize' => 2,
24 'lineNumbers' => true,
25 'theme' => 'default',
26 'mode' => 'htmlmixed',
27 'cdnURL' => $this->cdn_url . $this->version,
28 );
29
30 $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
31 $settings = wp_parse_args( $settings, $default_settings );
32
33 echo $this->field_before();
34 echo '<textarea name="'. esc_attr( $this->field_name() ) .'"'. $this->field_attributes() .' data-editor="'. esc_attr( json_encode( $settings ) ) .'">'. $this->value .'</textarea>';
35 echo $this->field_after();
36
37 }
38
39 public function enqueue() {
40
41 $page = ( ! empty( $_GET[ 'page' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'page' ] ) ) : '';
42
43 // Do not loads CodeMirror in revslider page.
44 if ( in_array( $page, array( 'revslider' ) ) ) { return; }
45
46 if ( ! wp_script_is( 'csf-codemirror' ) ) {
47 wp_enqueue_script( 'csf-codemirror', esc_url( $this->cdn_url . $this->version .'/lib/codemirror.min.js' ), array( 'csf' ), $this->version, true );
48 wp_enqueue_script( 'csf-codemirror-loadmode', esc_url( $this->cdn_url . $this->version .'/addon/mode/loadmode.min.js' ), array( 'csf-codemirror' ), $this->version, true );
49 }
50
51 if ( ! wp_style_is( 'csf-codemirror' ) ) {
52 wp_enqueue_style( 'csf-codemirror', esc_url( $this->cdn_url . $this->version .'/lib/codemirror.min.css' ), array(), $this->version );
53 }
54
55 }
56
57 }
58 }
59