I have the plugin CKEditor for Wordpress installed and want to show a CKEditor on a custom admin page I made. I use the wordpress function wp_editor() to show it.
wp_editor("initial content", "uniqueid");
The problem is it shows a completely white editor instead of the CKEditor (so: a large white rectangle with a HTML and Visual above). It produces the following html on my page (I left out the "HTML" and "Add Media" button):
<div id="wp-uniqueid-wrap" class="wp-editor-wrap tmce-active"><link rel="stylesheet" id="editor-buttons-css" href="/wp-includes/css/editor.min.css?ver=4.1.1" type="text/css" media="all">
<div id="wp-uniqueid-editor-tools" class="wp-editor-tools">
<a id="uniqueid-tmce" class="hide-if-no-js wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">Visual</a>
</div>
<div id="wp-uniqueid-editor-container" class="wp-editor-container">
<textarea class="wp-editor-area theEditor" rows="10" cols="40" name="uniqueid" id="uniqueid"><p>initial content</p></textarea>
</div>
</div>
Only when I click the "Visual" tab I get the CKEditor. Only then does it look exactly like the one in my regular admin pages (Posts and Pages).
So, my question is what should I add to my custom admin page or to my custom functions to have the CKEditor appear on a custom admin page like it appears on the "edit post" and "edit page" pages, without the user having to click the Visual tab to show the editor and its content?
Or, the other way around, which code is added to the regular "edit post" and "edit page" pages in order for the CKEditor to show up normally?
EDIT: I managed to get it work partly. There is still something bugging me. I added the following after the wp_editor() call:
<script>
window.onload = function(){
CKEDITOR.replace( "uniqueid" );
};
</script>
Now I see the editor.