the_editor

Definition:
function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {}

Display visual editor forms: TinyMCE, or HTML, or both.
The amount of rows the text area will have for the content has to be between 3 and 100 or will default at 12. There is only one option used for all users, named ‘default_post_edit_rows’.

Parameters

  • string $content: Textarea content.
  • string $id: Optional, default is ‘content’. HTML ID attribute value.
  • string $prev_id: Optional, default is ‘title’. HTML ID name for switching back and forth between visual editors.
  • bool $media_buttons: Optional, default is true. Whether to display media buttons.
  • int $tab_index: Optional, default is 2. Tabindex for textarea element.
  • $extended

Defined filters

  • the_editor
    apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n")
  • the_editor_content
    apply_filters('the_editor_content', $content)

Defined actions

  • media_buttons
    do_action( 'media_buttons' );

Source code

function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {

	$rows = get_option('default_post_edit_rows');

	if (($rows < 3) || ($rows > 100))

		$rows = 12;



	if ( !current_user_can( 'upload_files' ) )

		$media_buttons = false;



	$richedit =  user_can_richedit();

	$class = '';



	if ( $richedit || $media_buttons ) { ?>

	<div id="editor-toolbar">

<?php

	if ( $richedit ) {

		$wp_default_editor = wp_default_editor(); ?>

		<div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>

<?php	if ( 'html' == $wp_default_editor ) {

			add_filter('the_editor_content', 'wp_htmledit_pre'); ?>

			<a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>

			<a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>

<?php	} else {

			$class = " class='theEditor'";

			add_filter('the_editor_content', 'wp_richedit_pre'); ?>

			<a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>

			<a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>

<?php	}

	}



	if ( $media_buttons ) { ?>

		<div id="media-buttons" class="hide-if-no-js">

<?php	do_action( 'media_buttons' ); ?>

		</div>

<?php

	} ?>

	</div>

<?php

	}

?>

	<div id="quicktags"><?php

	wp_print_scripts( 'quicktags' ); ?>

	<script type="text/javascript">edToolbar()</script>

	</div>



<?php

	$the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");

	$the_editor_content = apply_filters('the_editor_content', $content);



	printf($the_editor, $the_editor_content);



?>

	<script type="text/javascript">

	edCanvas = document.getElementById('<?php echo $id; ?>');

<?php if ( ! $extended ) { ?>	jQuery('#ed_fullscreen, #ed_more').hide();<?php } ?>

	</script>

<?php

	// queue scripts

	if ( $richedit )

		add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );

	elseif ( $extended )

		add_action( 'admin_print_footer_scripts', 'wp_quicktags', 25 );



}

3005

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: