<?php
/*
Plugin Name: Taggr
Plugin URI: http://example.com/wordpress-plugins/my-plugin
Description: Premium plugin for image and photo tagging
Version: 1.0
Author: Tee Kai Yang
Author URI: http://wrox.com
License: GPLv2
*/
add_action(\'init\', \'register_tagging_post\');
//create taggr post type
function register_tagging_post(){
$tagging_args = array(
\'public\' => true,
\'supports\' => array(
\'title\',
\'thumbnail\'
),
\'query_var\' => \'tagging\',
\'rewrite\' => array(
\'slug\' => \'taggr\',
\'with_front\' => false
),
\'labels\' => array(
\'name\' => \'Taggr Albums\',
\'singular_name\' => \'Album\',
\'add_new\' => \'Add New Album\',
\'add_new_item\' => \'Add New Album\',
\'edit_item\' => \'Edit Album\',
\'new_item\' => \'New Album\',
\'view_item\' => \'View Album\',
\'search_items\' => \'Search Albums\',
\'not_found\' => \'No Albums Found\',
\'not_found_in_trash\' => \'No Albums Found In Trash\'
),
\'menu_icon\' => plugins_url() . \'/taggr/images/PhotoAlbum.png\',
\'menu_position\' => 80,
);
register_post_type(\'tagging\', $tagging_args);
}
add_action( \'add_meta_boxes\', \'taggr_create_meta\' );
function taggr_create_meta(){
add_meta_box( \'taggrMeta\', \'Upload and edit photos/images\', \'taggr_meta_function\', \'tagging\', \'normal\', \'high\' );
function taggr_meta_function(){
?>
<?php wp_editor("Enter your text", "my_editor"); ?>
<script>
window.onload = function(){
alert(tinyMCE.editors[0].getContent());
}
</script>
<?php
}
}
?>
以上是我的代码,我在metabox中创建了一个自定义帖子和一个tinyMCE文本编辑器。但为什么执行时
alert(tinyMCE.editors[0].getContent());
行,它不工作,也不显示编辑器的内容。firebug显示以下错误:
TypeError: tinyMCE.editors[0] is undefined