PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.1
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.1
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
darkify / admin / ta-framework / fields / wp_editor / wp_editor.php

wp_editor.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.2.1, at admin/ta-framework/fields/wp_editor/wp_editor.php

114 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die;
3 } // Cannot access directly.
4 /**
5 *
6 * Field: wp_editor
7 *
8 * @since 1.0.0
9 * @version 1.0.0
10 */
11 if ( ! class_exists( 'DRK_LITE_Field_wp_editor' ) ) {
12 class DRK_LITE_Field_wp_editor extends DRK_LITE_Fields {
13
14
15 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
16
17 parent::__construct( $field, $value, $unique, $where, $parent );
18 }
19
20 public function render() {
21
22 $args = wp_parse_args(
23 $this->field,
24 array(
25 'tinymce' => true,
26 'quicktags' => true,
27 'media_buttons' => true,
28 'wpautop' => false,
29 'height' => '',
30 )
31 );
32
33 $attributes = array(
34 'rows' => 10,
35 'class' => 'wp-editor-area',
36 'autocomplete' => 'off',
37 );
38
39 $editor_height = ( ! empty( $args['height'] ) ) ? ' style="height:' . esc_attr( $args['height'] ) . ';"' : '';
40
41 $editor_settings = array(
42 'tinymce' => $args['tinymce'],
43 'quicktags' => $args['quicktags'],
44 'media_buttons' => $args['media_buttons'],
45 'wpautop' => $args['wpautop'],
46 );
47
48 echo wp_kses_post( $this->field_before() );
49
50 echo ( drk_lite_wp_editor_api() ) ? '<div class="drk_lite-wp-editor" data-editor-settings="' . esc_attr( wp_json_encode( $editor_settings ) ) . '">' : '';
51
52 echo '<textarea name="' . esc_attr( $this->field_name() ) . '"' . wp_kses_post( $this->field_attributes( $attributes ) ) . wp_kses_post( $editor_height ) . '>' . wp_kses_post( $this->value ) . '</textarea>';
53
54 echo ( drk_lite_wp_editor_api() ) ? '</div>' : '';
55
56 echo wp_kses_post( $this->field_after() );
57 }
58
59 public function enqueue() {
60
61 if ( drk_lite_wp_editor_api() && function_exists( 'wp_enqueue_editor' ) ) {
62
63 wp_enqueue_editor();
64
65 $this->setup_wp_editor_settings();
66
67 add_action( 'print_default_editor_scripts', array( $this, 'setup_wp_editor_media_buttons' ) );
68
69 }
70 }
71
72 // Setup wp editor media buttons
73 public function setup_wp_editor_media_buttons() {
74
75 if ( ! function_exists( 'media_buttons' ) ) {
76 return;
77 }
78
79 ob_start();
80 echo '<div class="wp-media-buttons">';
81 do_action( 'media_buttons' );
82 echo '</div>';
83 $media_buttons = ob_get_clean();
84
85 // Enqueue the script instead of echoing it
86 wp_enqueue_script( 'drk-lite-media-buttons', plugin_dir_url( __FILE__ ) . 'your-script.js', array( 'jquery' ), null, true );
87
88 // Pass data to the script using wp_localize_script
89 wp_localize_script( 'drk-lite-media-buttons', 'drk_lite_media_buttons', $media_buttons );
90 }
91
92 // Setup wp editor settings
93 public function setup_wp_editor_settings() {
94
95 if ( drk_lite_wp_editor_api() && class_exists( '_WP_Editors' ) ) {
96
97 $defaults = apply_filters(
98 'drk_lite_wp_editor',
99 array(
100 'tinymce' => array(
101 'wp_skip_init' => true,
102 ),
103 )
104 );
105
106 $setup = _WP_Editors::parse_settings( 'drk_lite_wp_editor', $defaults );
107
108 _WP_Editors::editor_settings( 'drk_lite_wp_editor', $setup );
109
110 }
111 }
112 }
113 }
114