| Server IP : 119.36.225.67 / Your IP : 43.159.78.200 Web Server : nginx/1.28.0 System : Linux 1763701629066 6.8.0-53-generic #55-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 15:37:52 UTC 2025 x86_64 User : www ( 1001) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.lengcat.cn/wp-content/themes/onenav/inc/framework/fields/wp_editor/ |
Upload File : |
<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
/**
*
* Field: wp_editor
*
* @since 1.0.0
* @version 1.0.0
*
*/
if ( ! class_exists( 'IOCF_Field_wp_editor' ) ) {
class IOCF_Field_wp_editor extends IOCF_Fields {
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
parent::__construct( $field, $value, $unique, $where, $parent );
}
public function render() {
$args = wp_parse_args( $this->field, array(
'tinymce' => true,
'quicktags' => true,
'media_buttons' => true,
'wpautop' => false,
'height' => '',
) );
$attributes = array(
'rows' => 10,
'class' => 'wp-editor-area',
'autocomplete' => 'off',
);
$editor_height = ( ! empty( $args['height'] ) ) ? ' style="height:'. esc_attr( $args['height'] ) .';"' : '';
$editor_settings = array(
'tinymce' => $args['tinymce'],
'quicktags' => $args['quicktags'],
'media_buttons' => $args['media_buttons'],
'wpautop' => $args['wpautop'],
);
echo $this->field_before();
echo ( iocf_wp_editor_api() ) ? '<div class="csf-wp-editor" data-editor-settings="'. esc_attr( json_encode( $editor_settings ) ) .'">' : '';
echo '<textarea name="'. esc_attr( $this->field_name() ) .'"'. $this->field_attributes( $attributes ) . $editor_height .'>'. $this->value .'</textarea>';
echo ( iocf_wp_editor_api() ) ? '</div>' : '';
echo $this->field_after();
}
public function enqueue() {
if ( iocf_wp_editor_api() && function_exists( 'wp_enqueue_editor' ) ) {
wp_enqueue_editor();
$this->setup_wp_editor_settings();
add_action( 'print_default_editor_scripts', array( $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 '<div class="wp-media-buttons">';
do_action( 'media_buttons' );
echo '</div>';
$media_buttons = ob_get_clean();
echo '<script type="text/javascript">';
echo 'var iocf_media_buttons = '. json_encode( $media_buttons ) .';';
echo '</script>';
}
// Setup wp editor settings
public function setup_wp_editor_settings() {
if ( iocf_wp_editor_api() && class_exists( '_WP_Editors') ) {
$defaults = apply_filters( 'iocf_wp_editor', array(
'tinymce' => array(
'wp_skip_init' => true
),
) );
$setup = _WP_Editors::parse_settings( 'iocf_wp_editor', $defaults );
_WP_Editors::editor_settings( 'iocf_wp_editor', $setup );
}
}
}
}