我使用以下代码将tinymce文本编辑器添加到我的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);我的问题是,如果我在编辑器中输入一些东西。它将数据保存在哪里?在哪张桌子上?
发布于 2012-04-30 18:16:36
根据你如何设置你的插件,这“可以”保存为一个选项,
即:
<?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中创建单独的表
祝你好运,马蒂
https://stackoverflow.com/questions/10377496
复制相似问题