field,
[
'tinymce' => true,
'quicktags' => true,
'media_buttons' => true,
'wpautop' => false,
'height' => '',
]
);
$attributes = [
'rows' => 10,
'class' => 'wp-editor-area',
'autocomplete' => 'off',
];
$editor_height = ( ! empty( $args['height'] ) ) ? ' style="height:' . esc_attr( $args['height'] ) . ';"' : '';
$editor_settings = [
'tinymce' => $args['tinymce'],
'quicktags' => $args['quicktags'],
'media_buttons' => $args['media_buttons'],
'wpautop' => $args['wpautop'],
];
echo wp_kses_post( $this->field_before() );
echo ( adminify_wp_editor_api() ) ? '
' : '';
echo '';
echo ( adminify_wp_editor_api() ) ? '
' : '';
echo wp_kses_post( $this->field_after() );
}
public function enqueue() {
if ( adminify_wp_editor_api() && function_exists( 'wp_enqueue_editor' ) ) {
wp_enqueue_editor();
$this->setup_wp_editor_settings();
add_action( 'print_default_editor_scripts', [ $this, 'setup_wp_editor_media_buttons' ] );
}
}
// Setup wp editor media buttons
public function setup_wp_editor_media_buttons() {
if ( ! function_exists( 'media_buttons' ) ) {
return;
}
ob_start();
echo '';
do_action( 'media_buttons' );
echo '
';
$media_buttons = ob_get_clean();
echo '';
}
// Setup wp editor settings
public function setup_wp_editor_settings() {
if ( adminify_wp_editor_api() && class_exists( '_WP_Editors' ) ) {
$defaults = apply_filters(
'adminify_wp_editor',
[
'tinymce' => [
'wp_skip_init' => true,
],
]
);
$setup = _WP_Editors::parse_settings( 'adminify_wp_editor', $defaults );
_WP_Editors::editor_settings( 'adminify_wp_editor', $setup );
}
}
}
}