PluginProbe
Cool Timeline (Horizontal & Vertical Timeline) / trunk
Cool Timeline (Horizontal & Vertical Timeline) vtrunk
3.4.0 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 2.2.3 2.3.3 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.6.1 2.7.1 2.8.3 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 All 79 releases
cool-timeline / admin / codestar-framework / fields / wp_editor / wp_editor.php

wp_editor.php in Cool Timeline (Horizontal & Vertical Timeline) trunk, at admin/codestar-framework/fields/wp_editor/wp_editor.php

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