Wordpress wp_editor() 不工作 [英] Wordpress wp_editor() not working

查看:28
本文介绍了Wordpress wp_editor() 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 wordpress 3.8 并创建了插件并显示了 wp_editor.

i used wordpress 3.8 and i create plugin and i displayed the wp_editor.

但它看起来像这样.

这是我的代码.

$content = "";
$edit_id = "slider_text_editor";
wp_editor( $content, $edit_id );

推荐答案

要正确使用 wp_editor 像这样使用它:

to properly use the wp_editor use it like this:

// add the admin settings and such
add_action('admin_init', 'wp_your_plugin_admin_init');
function wp_your_plugin_admin_init(){
register_setting( 'wp_your_plugin_settings', 'wp_your_plugin_settings', 'wp_your_plugin_settings_validate');
add_settings_field('wp_your_plugin_user_custom_text', __('Enter your message','wp_your_plugin'), 'wp_your_plugin_user_custom_text', 'wp_your_plugin', 'wp_your_plugin_main');

function wp_your_plugin_user_custom_text() {
$options = get_option('wp_your_plugin_settings');
$settings  = array('media_buttons' => true,'textarea_rows' => 5,'textarea_name' => 'user_custom_text');
wp_editor( $options['user_custom_text'],'user_custom_text', $settings  );}  

// validate  
function wp_your_plugin_settings_validate() {
$options = get_option('wp_your_plugin_settings');


if ( empty($_POST['user_custom_text']) ){
    $options['user_custom_text'] =  __('Enter your own content, it will be below the original message','wp_your_plugin');// as set when the plugin activated
}else{
    $options['user_custom_text'] =  wp_kses_post($_POST['user_custom_text']) ;}// u need to Sanitize to be able to get the media to work

这篇关于Wordpress wp_editor() 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆