Front end tiny mce not working

Discussion in 'Content Management' started by Nattsurfaren, Jun 11, 2016.

  1. #1
    Need some help figuring out why the tiny-mce doesn't work the old way.
    I know you normally use this solution:

    <?php the_editor( 'CONTENT TO EDIT' ); ?>
    wp_enqueue_script('editor');

    But something with this bothers me when it feels like I get the
    slow, sticky and resource consuming version of the rich text edtior.
    I want the option to use the tiny-mce component instead of rely on
    wordpress.

    I try to put the editor in a short code:
    <div id="editorcontainer"><textarea name="myplugin_field" type="text" id="myplugin_field" cols="80" rows="20"><?php print $myplugin_field; ?></textarea></div>

    javascript
    tinyMCE.execCommand('mceAddControl', true, 'myplugin_field');


    Then i use functions.php to prepare it.
    add_filter('admin_head','ShowTinyMCE');
    function ShowTinyMCE() {
    // 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');
    }

    I try to enqueue the tiny-mce
    wp_enqueue_script('tinymce', home_url() . '/wp-includes/js/tinymce/tinymce.min.js');

    I also found this code that doesn't work:
    add_action('admin_head', 'load_tiny_mce');
    function load_tiny_mce()
    {
    wp_tiny_mce(false, array(
    'mode' => 'specific_textareas',
    'editor_selector' => 'tinymce-textarea'
    ));
    }

    The purpose of all this is to make a front-end post form page.

    Appreciate any help
     
    Nattsurfaren, Jun 11, 2016 IP