2012-04-30 40 views
1

我使用这些代码添加TinyMCE的文本编辑器到我的WP插件:添加在WP插件的富文本编辑

add_action('admin_init', 'editor_admin_init'); 
add_action('admin_head', 'editor_admin_head'); 

function editor_admin_init(){ 
wp_enqueue_script('post'); 
wp_enqueue_script('word-count'); 
wp_enqueue_script('editor'); 
wp_enqueue_script('media-upload'); 
} 

function editor_admin_head(){ 
wp_tiny_mce(); 
} 

并显示它:

the_editor("", "content", "", false); 

我的问题是,如果我输入一些东西进入编辑器。它在哪里保存数据?在哪张桌子上?

回答

2

取决于你如何设置你的插件,这“可以”保存为一个选项,

即:

<?php 

// Grab our options, IF your using Options 
// if not you can create and use your own tables to store data 
$options = get_option('your_plugin_options'); 

// using a hidden field on the form called action with a value of 'save'  
if(isset($_POST['action']) && ($_POST['action']=='save')){ 

    $options['main_content'] = trim($_POST['content']); 

    $newOptions = array('main_content' => $options['main_content']); 

    update_option('your_plugin_options', $newOptions); 
} 
?> 

这将WordPress的表wp_options

然后内创建一个选项,如果你想参考这个选项,你只需给它留言。

<?php 
$options = get_option('your_plugin_options'); 
$new_content = $options['main_content']; 

echo $options['main_content']; 
//or 
echo $new_content; 
?> 

希望这点你在正确的方向。 已经读通过:

//使用get选项 http://codex.wordpress.org/Function_Reference/get_option

//更新选项 http://codex.wordpress.org/Function_Reference/update_option

//创建你的插件 http://codex.wordpress.org/Creating_Tables_with_Plugins

好运 马蒂单独的表