PluginProbe
Video Player for YouTube – Embed Videos Your Visitors Will Love to Watch / 2.0.5
Video Player for YouTube – Embed Videos Your Visitors Will Love to Watch v2.0.5
2.1.1 2.1.0 trunk 1.0 1.1 1.2 1.4.2 1.5.2 1.5.5 1.6.1 1.6.2 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
yt-player / admin / framework / fields / code_editor / code_editor.php

code_editor.php in Video Player for YouTube – Embed Videos Your Visitors Will Love to Watch 2.0.5, at admin/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 = '5.64.0';
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