Support » Themes and Templates » Adding TinyMCE buttons (on front)

  • Begin

    (@bentalgad)


    I’m using this code (from this tutorial):

    // Hooks your functions into the correct filters
    function my_add_mce_button() {
    	// check user permissions
    	if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
    		return;
    	}
    	// check if WYSIWYG is enabled
    	if ( 'true' == get_user_option( 'rich_editing' ) ) {
    		add_filter( 'mce_external_plugins', 'my_add_tinymce_plugin' );
    		add_filter( 'mce_buttons', 'my_register_mce_button' );
    	}
    }
    add_action('admin_head', 'my_add_mce_button');
    
    // Declare script for new button
    function my_add_tinymce_plugin( $plugin_array ) {
    	$plugin_array['my_mce_button'] = get_template_directory_uri() .'/js/mce-button.js';
    	return $plugin_array;
    }
    
    // Register new button in the editor
    function my_register_mce_button( $buttons ) {
    	array_push( $buttons, 'my_mce_button' );
    	return $buttons;
    }

    to add a button to my TinyMCE editor and it does, but it doesn’t add this to the TinyMCE when used on the front-end (for a rich text field). and i need it to 🙂

    Any ideas?

    Thanks.

  • The topic ‘Adding TinyMCE buttons (on front)’ is closed to new replies.