PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.2.5
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.2.5
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 / wp_editor / wp_editor.php

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

108 lines 2.9 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( 'ADMINIFY_Field_wp_editor' ) ) {
11 class ADMINIFY_Field_wp_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 $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 ( adminify_wp_editor_api() ) ? '<div class="adminify-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 ( adminify_wp_editor_api() ) ? '</div>' : '';
49
50 echo $this->field_after();
51
52 }
53
54 public function enqueue() {
55
56 if ( adminify_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 adminify_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 ( adminify_wp_editor_api() && class_exists( '_WP_Editors') ) {
91
92 $defaults = apply_filters( 'adminify_wp_editor', array(
93 'tinymce' => array(
94 'wp_skip_init' => true
95 ),
96 ) );
97
98 $setup = _WP_Editors::parse_settings( 'adminify_wp_editor', $defaults );
99
100 _WP_Editors::editor_settings( 'adminify_wp_editor', $setup );
101
102 }
103
104 }
105
106 }
107 }
108