WordPress.org

Forums

[resolved] Adding Editor on my plugin - need html/visual tabs to look right (6 posts)

  1. tripleGmax
    Member
    Posted 5 years ago #

    So I have found several posts on this support forum and other places on how to place the editor on my plugin, but I still have an issue with the visual/html toggle buttons. They are there and they work, but it appears the CSS is not working for them.

    I have tested to see what css file is controlling them, but I have come up short handed.

    Here is my code so it helps someone diagnose this...

    add_filter('admin_head','show_tinyMCE');
    function show_tinyMCE() {
    	// conditions here
    	wp_enqueue_script( 'common' );
    	wp_enqueue_script( 'jquery-color' );
    	wp_print_scripts('editor');
    	if (function_exists('add_thickbox')) add_thickbox();
    	wp_print_scripts('media-upload');
    	if (function_exists('wp_tiny_mce')) wp_tiny_mce();
    	wp_admin_css();
    	wp_enqueue_script('utils');
    	do_action("admin_print_styles-post-php");
    	do_action('admin_print_styles');
    	remove_all_filters('mce_external_plugins');
    }

    and then where i display it i have

    <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
    				<?php the_editor($msgblock,'content','content', false); ?>
    				<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    				<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
                    </div>
  2. tripleGmax
    Member
    Posted 5 years ago #

    AHA! i figured out that I need the <div id="poststuff"> surrounding the editor, otherwise it wont show the correct css for the html and visual editor buttons.

  3. calleo
    Member
    Posted 5 years ago #

    Really helpfull! :)

    Althought I had to add some lines to the initialization (probably depending on the plug-ins activated).

    Here's what I am using:

    add_filter('admin_head','myplugin_tinymce');
    
    function myplugin_tinymce()
    {
      wp_enqueue_script('common');
      wp_enqueue_script('jquery-color');
      wp_admin_css('thickbox');
      wp_print_scripts('post');
      wp_print_scripts('media-upload');
      wp_print_scripts('jquery');
      wp_print_scripts('jquery-ui-core');
      wp_print_scripts('jquery-ui-tabs');
      wp_print_scripts('tiny_mce');
      wp_print_scripts('editor');
      wp_print_scripts('editor-functions');
      add_thickbox();
      wp_tiny_mce();
      wp_admin_css();
      wp_enqueue_script('utils');
      do_action("admin_print_styles-post-php");
      do_action('admin_print_styles');
      remove_all_filters('mce_external_plugins');
    }

    Maybe it's possible to tweak it a bit. And the HTML:

    <div id="poststuff">
    <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea"><?php the_editor("<strong>hello world strong!</strong>"); ?>
    <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
    <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
    </div>
    </div>

    Thanks!
    Carl

  4. senica@gmail.com
    Member
    Posted 4 years ago #

    Hey,

    Thank you for posting the code above. Works great.

    My box always goes to the top of the screen like it is positioned absolutely. Any ideas how I can get it to stay where I am putting it?

  5. senica@gmail.com
    Member
    Posted 4 years ago #

    Nevermind. I just did a bad implementation :)

    This code works great!

  6. petrusfajarsubekti
    Member
    Posted 4 years ago #

    I still don't understand.
    Where i should put this code on.
    Will it affects the visual of my blog?
    or just to make the editor button for plug-in in WP admin?

Topic Closed

This topic has been closed to new replies.

About this Topic