• How can I remove add media buttons area from tinymce editor? I also don’t want to give my authors an option to choose html editor, how can I hide it? Thanx.

Viewing 13 replies - 1 through 13 (of 13 total)
  • I can help solve your problem. So near as I can tell, it’s a hack though, and not a pluggable solution.

    \wp-includes\general_template.php, at line 921, is where the editor lives. If you wanted to yank HTML ability, you’d comment out line 933:
    <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>');"><?php _e('HTML'); ?></a>

    If you wanted HTML only, you could comment out 938:
    <a id="edButtonPreview" onclick="switchEditors.go('<?php echo $id; ?>');"><?php _e('Visual'); ?></a>

    In either instance, I’d suggest something to inhibit their ability to choose in their profiles. Something like the following (which *IS* pluggable):

    //Disallow HTML editing
    function strip_htmleditor($origvalue)
    {
    	return !(current_user_can('edit_published_posts'));
    }
    add_filter('user_can_richedit', 'strip_htmleditor');

    If there exists a pluggable solution to your problem, I’d love to hear it, since I’m trying to customize a site rather similarly at present.

    Oh, and the media buttons (which aren’t the same as the answer I just gave, because you kinda asked two questions): in the aformentioned function, $media_buttons is one of the arguments, defaulted to true (and not explicitly set when called by edit-form-advanced.php). Set it to false somewhere, either in the call, or in the argument list, or early in the code, and the media upload buttons will go away.

    Again, a pluggable solution is welcome, if someone knows one.

    Mwahaha.

    I love it when I kinda solve my own problem. But this answers part of yours (I think) so hooray for both of us.

    //Remove media upload area
    function curb_uploads($initcontext)
    {
    	if ( ! current_user_can('manage_options') ) {
    		$initcontext = 'No Uploads';
    	}
    	return $initcontext;
    }
    add_filter('media_buttons_context', 'curb_uploads');

    Thread Starter equ13

    (@equ13)

    Steegness, I greatly appreciate your help! “Remove media upload area” code works perfectly for me, thanx! But there is a little problem with disallowing html editor. The code you’ve provided above hides from my authors visual editor instead of hiding html editor. Could you please help with a “plugable solution” for this one too? Thanks alot!

    Which piece wasn’t working?

    To hide the HTML option, my suggestion was commenting out line 923 in general_template.php. Did that not go for you?

    I wish I could see a pluggable solution for that, but there aren’t any hooks in that area that I can find. ??

    Thread Starter equ13

    (@equ13)

    //Disallow HTML editing
    function strip_htmleditor($origvalue)
    {
    	return !(current_user_can('edit_published_posts'));
    }
    add_filter('user_can_richedit', 'strip_htmleditor');

    This code hides from my authors visual editor instead of hiding html editor.

    Thread Starter equ13

    (@equ13)

    Is it possible to hide html editor from authors and show it to admins? I can hide the html option by commenting those lines out, as you suggested, but my admins also wan’t see it ??

    Ah. Duhr.

    Sorry about that. Older code that I sorta fiddled with to make it fit the problem at hand.

    The trick is that you ALWAYS want user_can_richedit to be true. So I guess you could just have:
    add_filter('user_can_richedit', TRUE)
    or something to that effect.

    To keep the HTML editor for folks other than authors, you’d need to hack around that general_template.php some more, and wrap the commentary in some kind of if statement (if (current_eser_can('manage_option') { HTMLEDITORCODE } else { COMMENTEDOUTHTMLEDITORCODE }

    Grain of salt: I’m making this up as I go along, same as you. Forgive me my trespasses.

    Thread Starter equ13

    (@equ13)

    Thanx! I’ll be trying next couple of days!

    I’d also like to remove the HTML editor button for authors and everyone else EXCEPT admin. If someone has the code or plugin to do it, please post it here.

    Thanks.

    I’m also trying to remove some of the media upload buttons for everyone EXCEPT admin. I only want admin to be able to upload movies and Flash. Everyone else should ONLY be able to upload images.

    I agree with popart: Only want the admin to be able to upload movies and Flash media, everyone else just images. I’m on shared hosting and don’t want my members to upload huge files and blow out my storage and/or bandwidth. Any tips other than WP core hacks that will get overwritten with updates?

    Just did a hack that likely won’t survive upgrades, but here it is anyway…

    In the file /wp-admin/includes/media.php under “function media_buttons()” delete the following code….

    <a href="{$video_upload_iframe_src}&amp;TB_iframe=true" id="add_video" class="thickbox" title='$video_title'><img src='images/media-button-video.gif' alt='$video_title' /></a>
    	<a href="{$audio_upload_iframe_src}&amp;TB_iframe=true" id="add_audio" class="thickbox" title='$audio_title'><img src='images/media-button-music.gif' alt='$audio_title' /></a>
    	<a href="{$media_upload_iframe_src}&amp;TB_iframe=true" id="add_media" class="thickbox" title='$media_title'><img src='images/media-button-other.gif' alt='$media_title' /></a>
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Media buttons area in TinyMCE editor’ is closed to new replies.