PluginProbe
Document Embedder – let visitors read files without downloading / 1.8.6
Document Embedder – let visitors read files without downloading v1.8.6
2.3.1 2.3.0 2.2.1 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.3 1.7.4 1.7.6 1.7.9 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 2.0.0 2.0.1 2.0.2 All 30 releases
document-emberdder / admin / framework / fields / wp_editor / wp_editor.php

wp_editor.php in Document Embedder – let visitors read files without downloading 1.8.6, at admin/framework/fields/wp_editor/wp_editor.php

108 lines 2.8 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: wp_editor
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'CSF_Field_wp_editor' ) ) {
11 class CSF_Field_wp_editor extends CSF_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 $args = wp_parse_args( $this->field, array(
20 'tinymce' => true,
21 'quicktags' => true,
22 'media_buttons' => true,
23 'wpautop' => false,
24 'height' => '',
25 ) );
26
27 $attributes = array(
28 'rows' => 10,
29 'class' => 'wp-editor-area',
30 'autocomplete' => 'off',
31 );
32
33 $editor_height = ( ! empty( $args['height'] ) ) ? ' style="height:'. esc_attr( $args['height'] ) .';"' : '';
34
35 $editor_settings = array(
36 'tinymce' => $args['tinymce'],
37 'quicktags' => $args['quicktags'],
38 'media_buttons' => $args['media_buttons'],
39 'wpautop' => $args['wpautop'],
40 );
41
42 echo $this->field_before();
43
44 echo ( csf_wp_editor_api() ) ? '<div class="csf-wp-editor" data-editor-settings="'. esc_attr( json_encode( $editor_settings ) ) .'">' : '';
45
46 echo '<textarea name="'. esc_attr( $this->field_name() ) .'"'. $this->field_attributes( $attributes ) . $editor_height .'>'. $this->value .'</textarea>';
47
48 echo ( csf_wp_editor_api() ) ? '</div>' : '';
49
50 echo $this->field_after();
51
52 }
53
54 public function enqueue() {
55
56 if ( csf_wp_editor_api() && function_exists( 'wp_enqueue_editor' ) ) {
57
58 wp_enqueue_editor();
59
60 $this->setup_wp_editor_settings();
61
62 add_action( 'print_default_editor_scripts', array( $this, 'setup_wp_editor_media_buttons' ) );
63
64 }
65
66 }
67
68 // Setup wp editor media buttons
69 public function setup_wp_editor_media_buttons() {
70
71 if ( ! function_exists( 'media_buttons' ) ) {
72 return;
73 }
74
75 ob_start();
76 echo '<div class="wp-media-buttons">';
77 do_action( 'media_buttons' );
78 echo '</div>';
79 $media_buttons = ob_get_clean();
80
81 echo '<script type="text/javascript">';
82 echo 'var csf_media_buttons = '. json_encode( $media_buttons ) .';';
83 echo '</script>';
84
85 }
86
87 // Setup wp editor settings
88 public function setup_wp_editor_settings() {
89
90 if ( csf_wp_editor_api() && class_exists( '_WP_Editors') ) {
91
92 $defaults = apply_filters( 'csf_wp_editor', array(
93 'tinymce' => array(
94 'wp_skip_init' => true
95 ),
96 ) );
97
98 $setup = _WP_Editors::parse_settings( 'csf_wp_editor', $defaults );
99
100 _WP_Editors::editor_settings( 'csf_wp_editor', $setup );
101
102 }
103
104 }
105
106 }
107 }
108