【发布时间】:2013-12-26 11:46:18
【问题描述】:
我使用了 wordpress 3.8 并创建了插件并显示了 wp_editor。
但它看起来像这样。
这是我的代码。
$content = "";
$edit_id = "slider_text_editor";
wp_editor( $content, $edit_id );
【问题讨论】:
我使用了 wordpress 3.8 并创建了插件并显示了 wp_editor。
但它看起来像这样。
这是我的代码。
$content = "";
$edit_id = "slider_text_editor";
wp_editor( $content, $edit_id );
【问题讨论】:
试试下面的代码:
wp_tiny_mce( false, $mce_config );
其中 $mce_config 应该是一个键=>值对数组,代表编辑器(tinymce)实例的配置设置。
可在此处找到配置设置。
http://wiki.moxiecode.com/index.php/TinyMCE:Configuration
或者,如果您愿意,也可以在此处找到涵盖关键点的简短文章。
http://www.keighl.com/2010/01/tinymce-in-wordpress-plugins/
如果您在实现代码时遇到问题,请告诉我,我自己在插件页面中使用过它,没有遇到任何问题.. ;)
欲了解更多信息,请访问:How to use Wordpress Text Editor in a custom plugin
谢谢
【讨论】:
要正确使用 wp_editor,请像这样使用它:
// 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
【讨论】: