Created
December 11, 2010 02:20
-
-
Save jaredwilli/737093 to your computer and use it in GitHub Desktop.
Add TinyMCE Metabox in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function additional_info() { | |
global $post; | |
$custom = get_post_custom($post->ID); | |
$additional_info = $custom["additional_info"][0]; | |
// this adds an extra tinymce field | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function() { | |
jQuery("#additional_info_textarea").addClass("mceEditor"); | |
if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) { | |
tinyMCE.execCommand("mceAddControl", false, "additional_info_textarea"); | |
} | |
}); | |
</script> | |
<style type="text/css">#additional_info_textarea_ifr { border:1px solid #DFDFDF; }</style> | |
<p><label style="display:none;">Any additional information:</label><br /> | |
<textarea cols="50" rows="5" id="additional_info_textarea" name="additional_info"><?php echo $additional_info; ?></textarea></p> | |
<?php | |
} | |
// enable new wysiwyg features | |
add_filter('mce_css', 'my_editor_style'); | |
function my_editor_style($url) { | |
if ( !empty($url) ) | |
$url .= ','; | |
// Change the path here if using sub-directory | |
$url .= trailingslashit( get_stylesheet_directory_uri() ) . 'editor-style.css'; | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment